Hollis,Virginia
HollisVJ at pgdp.usec.com
Thu Feb 5 11:32:21 CST 2004
I have the code shown below on a command button that closes a form. The form is a data entry form with a checkbox that will cancel the request by changing the status to 3 (canceled). If the status = canceled then the form will close. If an entry has been made on the form, there are certain required fields that must be completed before closing. Problem: Everything works fine except when I check the Cancel box. The status changes from 1 (Pending) to 3 (Canceled) & the form will close, but I get an error, "Can't find frmPermitEntry refered to in a macro of visual basic code". I tried commenting out different sections of the code, but I can't find the problem. What I don't understand, I have used this same code before without any problems. What am I missing? ******************** If PStatusID = 3 Then DoCmd.Close 'Request has been canceled If Forms!frmPermitEntry.Dirty = True Then 'Data Entered? Yes If Len(PRequestorID & "") = 0 Then MsgBox "A requestor must be entered." & vbCrLf, vbCritical, " Entry Required" PRequestorID.SetFocus ElseIf Len(PNeedByDate & "") = 0 Then MsgBox "The date needed must be entered." & vbCrLf, vbCritical, " Entry Required" PNeedByDate.SetFocus ElseIf Len(PTypeWork & "") = 0 Then MsgBox "The type of work must be entered." & vbCrLf, vbCritical, " Entry Required" PTypeWork.SetFocus Else Response = MsgBox("Do you want to Exit?", vbYesNo + vbQuestion, "Exit") If Response = vbNo Then PRequestorID.SetFocus Else DoCmd.RunCommand acCmdSaveRecord DoCmd.Close acForm, "frmPermitEntry" End If End If Else DoCmd.Close acForm, "frmPermitEntry" End If