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

ipon70

Board Regular
Joined
May 8, 2013
Messages
90
Office Version
  1. 2016
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
 
I'm a bit surprised that it seems no one ever asked you to please post indented code within code tags (by using VBA button on posting toolbar). You don't have to of course, but I for one won't try to follow code like that. Too easy to miss something. Anyway, if the error is what I think it is, none of that code matters. The problem will be at the top of a module somewhere in the declarations section where you're using API calls. If so, it will begin with Declare ... and might look like this:

Declare PtrSafe Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

However, that one is 64 bit compatible so yours won't say PtrSafe. If you find any, you'll need to convert them, but not necessarily all of them. Converting where it's not necessary will cause code to fail. You need to also allow for 32 vs 64 bit compilation if it needs to run in both bitness versions.
 
Upvote 0
I'm a bit surprised that it seems no one ever asked you to please post indented code within code tags (by using VBA button on posting toolbar). You don't have to of course, but I for one won't try to follow code like that. Too easy to miss something. Anyway, if the error is what I think it is, none of that code matters. The problem will be at the top of a module somewhere in the declarations section where you're using API calls. If so, it will begin with Declare ... and might look like this:

Declare PtrSafe Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

However, that one is 64 bit compatible so yours won't say PtrSafe. If you find any, you'll need to convert them, but not necessarily all of them. Converting where it's not necessary will cause code to fail. You need to also allow for 32 vs 64 bit compilation if it needs to run in both bitness versions.
Yeah no one has ever said anything about posting code, but I found the button so I am trying it.
So the entire code is what I posted, so I need to add at the top declare statement like in the "Sub Edit db section? Am I understanding that correct?

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
 
Upvote 0
You'll need to post the other 2 subs that one is calling db_delete_entry and Clear_edit
 
Upvote 0
You'll need to post the other 2 subs that one is calling db_delete_entry and Clear_edit
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

VBA Code:
Sub Clear_edit()
Sheets("REVIEW").Unprotect Password:="123456"
Worksheets("REVIEW").Activate
Application.ScreenUpdating = False
Range("M4").Select
Selection.ClearContents
Range("M4").Select
Application.ScreenUpdating = True
Sheets("REVIEW").Protect Password:="123456"
End Sub
 
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).
 
Upvote 0
I'm not getting an error with 365 64bit (and there is nothing in those codes that look 64bit specific, and that error is not the one you usually get when t isn't 64bit compatiable)
I would have a look at your references and see if any are marked as MISSING
 
Last edited:
Upvote 0
If i <= 1 Then
Shouldn't that be X?
VBA Code:
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
 
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.
 
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