Possible Bug???

Sam Summers

Registered User.
Local time
Today, 01:29
Joined
Sep 17, 2001
Messages
939
I have never had this before and have been trying to solve it for the last 14 hours.

Quite simply, I have a form (EditAccess) that is based on a Table and on it is a button to delete the record. I used the wizard to create the button.
However when I click on the button I am getting a message saying that the program cannot find the Form 'ViewbyLocation' referred to in a Macro expression or Visual Basic code. And that the form may not exist or be closed. Or that their may be a compile error in Visual Basic module for the form.

The form it is mentioning is not used in this routine and is closed.
So I'm baffled as to what its on about.

This is all the code for the form 'EditAccess':-

Option Compare Database
Option Explicit

Private Sub Delete_Click()
On Error GoTo Err_Delete_Click

Dim Msg, Style, Title, Response, MyString
DoCmd.Beep
Msg = "Are you sure you want to remove this item?"
Style = vbOKCancel + vbExclamation + vbDefaultButton1
Title = "Confirm Delete" ' Define title.
Response = MsgBox(Msg, Style, Title)
If Response = vbOK Then ' User chose Yes.
'Me.AllowEdits = True
'Me.AllowAdditions = True
'Me.AllowDeletions = True
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
DoCmd.Close acForm, "EditAccess"

Else

End If

Exit_Delete_Click:
Exit Sub

Err_Delete_Click:
MsgBox Err.Description
Resume Exit_Delete_Click

End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Form_BeforeUpdate

If Me.tbProperSave.Value = "No" Then
Beep
MsgBox "Please Save This Record!" & vbCrLf & vbLf & "You can not advance to another record until you either 'Save' the changes made to this record or 'Undo' your changes.", vbExclamation, "Save Required"
DoCmd.CancelEvent
Exit Sub
End If

Exit_Form_BeforeUpdate:
Exit Sub

Err_Form_BeforeUpdate:
If Err = 3020 Then 'Update or CancelUpdate without AddNew or Edit
Exit Sub
Else
MsgBox Err.Number, Err.Description
Resume Exit_Form_BeforeUpdate
End If

End Sub

Private Sub Form_Current()
On Error GoTo Err_Form_Current

Me.tbProperSave.Value = "No"

Exit_Form_Current:
Exit Sub

Err_Form_Current:
MsgBox Err.Number, Err.Description
Resume Exit_Form_Current

End Sub

Private Sub ItemSave_Click()
On Error GoTo Err_ItemSave_Click

If IsNull(ItemNo) Or IsNull(LocationID) Then
Beep
MsgBox "All required fields must be completed before you can save a record.", vbCritical, "Invalid Save"
Exit Sub
End If

Beep
Dim Msg, Style, Title, Response, MyString
DoCmd.Beep
Msg = "Do you want to save these changes?"
Style = vbOKCancel + vbExclamation + vbDefaultButton1
Title = "Confirm changes" ' Define title.
Response = MsgBox(Msg, Style, Title)
If Response = vbOK Then
DoCmd.OpenQuery "ReCertify1", acNormal, acEdit
Me.tbProperSave.Value = "Yes"
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenQuery "EditDate1", acNormal, acAdd
DoCmd.Close acForm, "EditAccess"

Else
DoCmd.RunCommand acCmdUndo
Me.tbProperSave.Value = "No"

End If

Exit_ItemSave_Click:
Exit Sub

Err_ItemSave_Click:
MsgBox Err.Description
Resume Exit_ItemSave_Click
End Sub
 
When you get the error message do you get the option to 'Debug'? If so this will highlight the offending code (if any)

Looking through your code I can't see any reference to a form called 'ViewByLocation'. Have you compiled your code as well?
 
I'm guessing you have a macro called ViewByLocation and it's that that Access is trying to reference.

I think the problem comes from this:

Code:
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70 
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

which, I believe, doesn't work.

Try changing those two lines to this:

Code:
DoCmd.RunCommand acCmdDeleteRecord
 
Thank you VERY VERY much for that, I was really panicking.

I shall remember that in future.
 

Users who are viewing this thread

Back
Top Bottom