Question : Compile Error: Variable not defined

Dear Expert -

I have code that was running fine for 7 months. Now out of the blue the command buttons do not work (with the following code) and I receive the following message "Compile Error: Variable not defined."

Here is the example of the code which was working:

Private Sub cmb_Delete_Profile_Click()

Dim strMsg As String
Dim intResponse As Integer

strMsg = "You are about to delete this Initiative would you like to continue?"

Response = MsgBox(strMsg, vbYesNo, "Are you sure?")

If intResponse = "6" Then

    Me.Refresh
    DoCmd.OpenQuery "QRY_REF_INTEGRITY_BUDGET"
    DoCmd.OpenQuery "QRY_REF_INTEGRITY_ATTRIBUTES"
    DoCmd.OpenQuery "QRY_REF_INTEGRITY_INITIATIVE_CHANGE"
    DoCmd.OpenQuery "QRY_DELETE_INIT_BUDGET"
    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
   
   
End If

End Sub

Answer : Compile Error: Variable not defined

Why not just use this:

Private Sub cmb_Delete_Profile_Click()

Dim strMsg As String
strMsg = "You are about to delete this Initiative would you like to continue?"

If MsgBox(strMsg, vbYesNo, "Are you sure?")= vbYes Then
    Me.Refresh
    DoCmd.OpenQuery "QRY_REF_INTEGRITY_BUDGET"
    DoCmd.OpenQuery "QRY_REF_INTEGRITY_ATTRIBUTES"
    DoCmd.OpenQuery "QRY_REF_INTEGRITY_INITIATIVE_CHANGE"
    DoCmd.OpenQuery "QRY_DELETE_INIT_BUDGET"
    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

End If   ' if not already in the code.

mx
Random Solutions  
 
programming4us programming4us