Hollis,Virginia
HollisVJ at pgdp.usec.com
Fri Feb 6 06:18:03 CST 2004
This works thanks!
Since this is a data entry form requesting services, they do not control the
status of the request, the Engineer does. So I added a checkbox they could
use if they entered data and half way through the entry, decide it isn't
needed.
Also, if they are going to submit the request, there are certain fields that
must be entered. This is where the If Len(PRequestorID & "") = 0, etc. Then
comes in.
I still want the form to be able to close if no entry has been made.
Does that make any sense? Anyway, thanks for the help.
Virginia
-----Original Message-----
From: Andy Lacey [mailto:andy at minstersystems.co.uk]
Sent: Thursday, February 05, 2004 4:17 PM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] Error Closing Form
Virginia
Once you've closed the form you can't refer to it. It's closed. I'm not
totally clear what you're doinmg but I 'think' you need to change it to an
IF...ELSEIF construct. At the moment you're issuing the close but the rest
of the code is running, then failing because the form can no longer be
referenced. Try making it:
If PStatusID = 3 Then
DoCmd.Close 'Request has been canceled
Else
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
End If
Andy Lacey
http://www.minstersystems.co.uk
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
> Hollis,Virginia
> Sent: 05 February 2004 20:27
> To: 'Access Developers discussion and problem solving'
> Subject: RE: [AccessD] Error Closing Form
>
>
> It isn't stopping, the form closes, Then I get the message so
> I don't know where the problem is. Is there a way I can tell?
>
> Virginia
>
> -----Original Message-----
> From: Gary Kjos [mailto:garykjos at hotmail.com]
> Sent: Thursday, February 05, 2004 2:10 PM
> To: accessd at databaseadvisors.com
> Subject: RE: [AccessD] Error Closing Form
>
>
> Did you comment out any "on error" statement so it stops an
> the error line?
> What line is it failing on?
>
>
>
> Gary Kjos
> garykjos at hotmail.com
>
>
>
>
>
> >From: "Hollis,Virginia" <HollisVJ at pgdp.usec.com>
> >Reply-To: Access Developers discussion and problem
> >solving<accessd at databaseadvisors.com>
> >To: "'Access Developers discussion and problem solving'"
> ><accessd at databaseadvisors.com>
> >Subject: [AccessD] Error Closing Form
> >Date: Thu, 05 Feb 2004 11:32:21 -0600
> >
> >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
> >_______________________________________________
> >AccessD mailing list
> >AccessD at databaseadvisors.com
> >http://databaseadvisors.com/mailman/listinfo/accessd
> >Website: http://www.databaseadvisors.com
>
> _________________________________________________________________
> Check out the new MSN 9 Dial-up - fast & reliable Internet
> access with prime
>
> features! http://join.msn.com/?pgmarket=en-us&page=dialup/home&ST=1
>
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/a> ccessd
> Website:
> http://www.databaseadvisors.com
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/a> ccessd
> Website:
> http://www.databaseadvisors.com
>
>
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com