VBA error in hidden module Error 32 bit to 64 bit?

ipon70

Board Regular
Joined
May 8, 2013
Messages
104
Office Version
  1. 365
Platform
  1. Windows
So I started getting this error ever since they upgraded to Officer 365.
The helpdesk says its a 32 vba error and needs to be 64 bit....

compileerror.png


Here is the code causing the issue. When the user clicks the delete button it literally doesn't even get the MSG box it just says that above message.

Sub Edit_db()
101:
Application.ScreenUpdating = False
Sheets("REVIEW").Visible = True
If Range("M4") = "" Then
MsgBox "You have left the ID number blank." & vbCrLf & "Please enter a item ID before pressing delete", vbQuestion + vbCritical + vbOK, "DATABASE ENTRY DELETE"
Exit Sub
Else
If Range("N4") = 1 Then
MsgBox "You are trying to delete a non item." & vbCrLf & "Please enter a valid item ID before pressing delete", vbQuestion + vbCritical + vbOK, "DATABASE ENTRY DELETE"
Exit Sub
Else
answer = MsgBox("This will delete the information shown from the database." & vbCrLf & "THIS CAN NOT BE UNDONE!" & vbCrLf & "Click YES to delete the information." & vbCrLf & "Click NO to cancel.", vbQuestion + vbCritical + vbYesNo, "DATABASE ENTRY DELETE")
If answer = vbYes Then
x = InputBox("Enter your Password.", "Password Required")
If x = "123456" Then
Call db_delete_entry
Call Clear_edit
Else
If i <= 1 Then
MsgBox "Invalid Password. Try again"
i = i + 3
GoTo 101:
Else
MsgBox "Incorrect password entered too many times. Try again later."
Exit Sub
End If
End If
End If
End If
End If
Application.ScreenUpdating = True

End Sub
 
You may also want to unprotect the project and then try a Debug - Compile as that should flag specifically what is causing the error
I might be able to pull that off, that would take some doing, but I will see about that one.
 
Upvote 0
Maybe I'd write it sorta like this
VBA Code:
Sub Edit_db()
Dim answer As Integer, i As Integer
Dim X As String, msg1 As String, msg2 As String, msg3 As String

msg1 = "You have left the ID number blank." & vbCrLf & "Please enter a item ID before pressing delete"
msg2 = "You are trying to delete a non item." & vbCrLf & "Please enter a valid item ID before pressing delete"
msg3 = "This will delete the information shown from the database." & vbCrLf & "THIS CAN NOT BE UNDONE!"
msg3 = msg3 & vbCrLf & "Click YES to delete the information." & vbCrLf & "Click NO to cancel."

On Error GoTo errHandler
'Sheets("REVIEW").Visible = True
If Range("M4") = "" Then 'no need to nest these tests if the result is to exit the sub
    MsgBox msg1, vbQuestion + vbCritical + vbOK, "DATABASE ENTRY DELETE"
    Exit Sub
End If

If Range("N4") = 1 Then
    MsgBox msg2, vbQuestion + vbCritical + vbOK, "DATABASE ENTRY DELETE"
    Exit Sub
End If
'if you get here, this becomes the main un-nested portion that was here before
'also, better to not alter application settings until all is OK

answer = MsgBox(msg3, vbQuestion + vbCritical + vbYesNo, "DATABASE ENTRY DELETE")
If answer = vbYes Then
    Do Until i = 3
        X = InputBox("Enter your Password.", "Password Required")
        If X = "123456" Then
            Application.ScreenUpdating = False
            'Call db_delete_entry
            'Call Clear_edit
            MsgBox "" 'this substitutes for Calls that I don't have
            Exit Do
        ElseIf i = 2 Then
            MsgBox "Incorrect password entered too many times. Try again later."
            Exit Sub
        Else
            MsgBox "Invalid Password. Try again"
            i = i + 1
        End If
    Loop
End If

exitHere:
Application.ScreenUpdating = True
Exit Sub

errHandler:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume exitHere

End Sub
I tend to put long message box text into string variables. Makes for shorter code lines that are easier to read, and if I want to edit the message, easier to do that too. Anything I commented out (e.g. because I don't have anything for the calls, or the right sheet name) would need to be fixed.
Ok, so dude!! this code change worked!!! Now it crashed with the same error except is says "module 2". on your new code this step which is the rem'd out statement of "db_delete_entry". I put back in. Below is a copy of module 2 and this statement, but your fixes worked for some reason, and I thank you for that!!
VBA Code:
Sub db_delete_entry()
Sheets("db").Unprotect Password:="123456"
Application.ScreenUpdating = False
Worksheets("db").Activate
Dim CompId As Range
Set CompId = Range("A:A").Find(what:=Range("DS1").Value, LookIn:=xlValues, lookat:=xlWhole)
Range(CompId.Offset(, 2), CompId.Offset(, 118)).ClearContents
CompId.Offset(, 1).Value = "DELETED"
UserName = Environ("username")
CompId.Offset(, 120).Value = UserName
CompId.Offset(, 121).Value = Date
Sheets("db").Protect Password:="123456"
Application.ScreenUpdating = True
End Sub
 
Upvote 0
I'm confused by that. It's working? Or it's not working?
So the original error module 9 is now gone, so its at least allowing a password now and getting to the "call" section before crashing. So I included what the call was for why it was now crashing.
 
Upvote 0
I'm confused by that. It's working? Or it's not working?
Ok, so I worked with a person at the other end over and over and over again....it is this one line of code causing the module 2 issue
'Set CompId = Range("A:A").Find(what:=Range("DS1").Value, LookIn:=xlValues, lookat:=xlWhole)

Do you see anything in there that would cause any issues, or something that should be written differently? Thanks again
 
Upvote 0
VBA Code:
Sub db_delete_entry()
Dim CompId As Range

''Sheets("db").Unprotect PassWord:="123456"
''Application.ScreenUpdating = False
''Worksheets("db").Activate
Worksheets("7").Activate
Set CompId = Range("A:A").Find(what:=Range("DS1").Value, LookIn:=xlValues, lookat:=xlWhole)
That last line does not cause any issue for me. Perhaps the only thing left is that I look at a copy of your wb if that's allowed. No guarantees if I do.
 
Upvote 0

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