excel vba works in one PC, but do not work on other PC

sathyaganapathi

Board Regular
Joined
Apr 29, 2021
Messages
81
Office Version
  1. 2016
Platform
  1. Windows
Hello, I have excel vba macro to update access table. this works in one PC, but, crashes in other PC. the configuration of PC is same. could anybody please help?


VBA Code:
Private Sub LabUpdate_Click()
    
  
    If Me.Department.value = "" Then
        MsgBox "Select a record from List to update"
        Call LabClear_Click
        Exit Sub
    End If
     
     If Me.ComplDate.value = "" Then
        Me.ComplDate.BackColor = vbRed
        MsgBox "Enter Date", vbCritical
        Exit Sub
    End If
     
    If Me.LabEmp.value = "" Then
        Me.LabEmp.BackColor = vbRed
        MsgBox "Please enter Employee name", vbCritical
        Exit Sub
    End If
    
     Sheets("Ctables").Range("u3").value = Me.ComplDate.value
    
    
    '''''''''''''''''''''''''''''''''''''''''
        
    Dim cnn As New ADODB.Connection
    Dim rst As New ADODB.Recordset
    Dim qry As String
        Dim Source As String
 
        Source = Me.Source.value
    
        cnn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Source
    
    If Me.txtId.value <> "" Then
        qry = "SELECT * FROM TBL_ClabInput WHERE ID = " & Me.txtId.value
    Else
        qry = "SELECT * FROM TBL_ClabInput Where ID = 0"
    End If
    
    rst.Open qry, cnn, adOpenKeyset, adLockOptimistic
    
    If rst.RecordCount = 0 Then
        rst.AddNew
    End If
    
    rst.Fields("CompletedTime").value = CDate(Me.ComplDate.value)
    rst.Fields("AnalysisBy").value = Me.LabEmp.value
    rst.Fields("Lab_Remarks").value = Me.LabRmrks.value
    rst.Fields("TimeToComplete").value = Me.TimeToCmplt.value 'VBA.Format(Val(Me.ComplDate.Value) - Val(Me.txtDate.Value), "HH:mm")
    rst.Fields("Comp_Shift").value = Sheets("Ctables").Range("v3").value
'    rst.Fields("BlankHourSamples").value = Sheets("Ctables").Range("v4").value
    
    
    rst.Update
    rst.Close
    cnn.Close
    
Call ClearAll_Click
     Sheets("Ctables").Range("u3").value = ""
    
ArchiveDbFile
     
    MsgBox "Updated Successfully", vbInformation
    Call List_box_Data
End Sub
 

Attachments

  • references.jpg
    references.jpg
    47.2 KB · Views: 12
I can't see anything in that code that should cause Excel to crash, I'm afraid.
Hi RoryA, Is there anything I have to check in the PC in which the excel stops working when the macro is executed?
Surprisingly the same macro works on other PC with same PC configuration..!
 
Upvote 0

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Are you using or defining the word 'value' anywhere, i was trying to work out why your .value is not .Value all the way through the code. I have seen this before when the word value is used as a variable somewhere in the code.

It's interesting that it fails on the first on that contains an underscore...
Hi Georgiboy, I have not defined the 'value'.. it is automatically changes to 'value' when I enter it as 'Value', especially in this coding. in other macros it is displayed as 'Value' only.
 
Upvote 0
I can't see anything in that code that should cause Excel to crash, I'm afraid.
Hi RoryA, Is there anything I have to check in the PC in which the excel stops working when the macro is executed?
Surprisingly the same macro works on other PC with same PC configuration..!
 
Upvote 0
There must be something different about the two machines but, as I said, I can't see any reason that that code would cause Excel to actually crash.

If you run Excel in safe mode (hold down the Ctrl key while starting Excel and answer Yes to the prompt) then run the workbook, does it work, or still crash.
 
Upvote 0
There must be something different about the two machines but, as I said, I can't see any reason that that code would cause Excel to actually crash.

If you run Excel in safe mode (hold down the Ctrl key while starting Excel and answer Yes to the prompt) then run the workbook, does it work, or still crash.
Hi RoryA, Thanks for your input. I will sure try that.
I have found one difference in both the PCs. The PC where macro works has the MS Office 32 bit and other where it dose not work is having MS Office 64 bit !! The macro was created with MS Office 32 bit. Is there any possibility to run this in 64 bit MS Office? what code corrections required for this? could you please suggest?
 
Upvote 0
I don't recall if there is a 64bit compatible version of the Windows Common Controls-2, which you have referenced. Are you actually using controls from that?
 
Upvote 0
I don't recall if there is a 64bit compatible version of the Windows Common Controls-2, which you have referenced. Are you actually using controls from that?
I have not used such controls. But, the only difference I found is the 32 bit vs 64 bit. Now, I am trying to load 32 bit MS Office to that particular PC with the help of IT team. Need to check if it works fine after loading 32 bit MS office.
 
Upvote 0
I don't recall if there is a 64bit compatible version of the Windows Common Controls-2, which you have referenced. Are you actually using controls from that?
Hi RoryA, After changing the MS Office to 32 bit pack the macro is working fine.
Thanks a lot for your support and guidance...
 
Upvote 0
Solution

Forum statistics

Threads
1,215,427
Messages
6,124,831
Members
449,190
Latest member
rscraig11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top