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

ipon70

Board Regular
Joined
May 8, 2013
Messages
102
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
 
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.
 
Upvote 0
I realize that
Yes but you asked if it should be X rather than i, it shouldn't be as X is the result of the message box and i is a separate counter, the error the OP posted isn't specific to being incompatible with 64bit btw.
After that, it will be 3 (i=1+3)
3 (i = 0 + 3), I don't know how many attempts the OP wants as that isn't producing the error, personally I would check Tools-References as a starting point,
 
Upvote 0
Thanks for trying, but I did say 'properly indented'? I've only indented and have not considered anything else about the code at this point. Indented, it would look more like this:
VBA Code:
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
No, I don't think you understand the other part yet. Did you look for a Declare statement? Ctrl+F then look for Declare. It would be at or near the very top of a module, (code page) not just above any procedure (macro).
I probably don't because that is how the code is in the excel sheet. This code was written about 5 years ago and there are no "declare" statements in anything.
 
Upvote 0
I realize that, but at first i will be 0. After that, it will be 3 (i=1+3) so only two tries as you say. Just wondering if the number of allowed attempts is supposed to be 3. FWIW I'd use a Do Until i = 3 if the goal is three attempts. I'd also get rid of all those nested If's, which I think should be ElseIf anyway.
Yes what is does it give them three tries and then stops popping up. This entire issue started when they upgraded from normal office 2016 to the new Office 365 everything fell apart, because people are using the web version now not an actual installed version of excel. The helpdesk said that if the vba code was 64 bit this wouldn't happen, so I set out trying to figure out what to do.
 
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.
I have moved this code into the sheet, and once someone gets in that gets the old error, I will have them try this. Thanks for the help.
 
Upvote 0
The web version of Excel doesn't support VBA so the code wouldn't work on there anyway.
Well here is the weird part, on the other side of this when they are entering items...it runs vba code and is perfectly happy. Its just the delete side that causes the issues.
 
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