I have an error flag that I want to use on a form.
I want to set flag on through error checks done on different events
I am then checking for this flag when the form is closed, but it doesn't
reconize the value on set while in an event.
so how do I set a field to be used publicly in any event on a form?
Thanks for any and all input.
Dim the flag in the Declarations section of a form's code module, like.
Public blFlag As Boolean
or
Dim blFlag As Boolean
or
Static blFlag As Boolean
Then set the flag in your subroutine. It's a good idea to clear it when
closing the form>
Public Sub Form_Close()
blFlag = Null
End Sub

Signature
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
>I have an error flag that I want to use on a form.
>
[quoted text clipped - 6 lines]
>
> Thanks for any and all input.
stickandrock - 14 Jan 2007 05:52 GMT
That is was I was thinking but here is some of my code....
Option Explicit
Dim errflg As String
errflg = "no"
Public Sub Command27_Click()
On Error GoTo Err_Command27_Click
MsgBox (errflg)
If (errflg = "no") Then
DoCmd.Close
End If
Exit_Command27_Click:
Exit Sub
Err_Command27_Click:
MsgBox Err.Description
Resume Exit_Command27_Click
End Sub
My msgbox shows as a null
> Dim the flag in the Declarations section of a form's code module, like.
>
[quoted text clipped - 20 lines]
> >
> > Thanks for any and all input.
Douglas J. Steele - 14 Jan 2007 11:16 GMT
You can't assign values to variables outside of a module.
Move the line
errflag = "no"
into the form's Load event.
(and just being picky, your message box couldn't have shown a Null: string
variables cannot contain Nulls (only Variants can). It would have been
showing a zero-length string (""))

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
> That is was I was thinking but here is some of my code....
> Option Explicit
[quoted text clipped - 45 lines]
>> >
>> > Thanks for any and all input.
stickandrock - 14 Jan 2007 18:58 GMT
abolutely correct
> You can't assign values to variables outside of a module.
>
[quoted text clipped - 57 lines]
> >> >
> >> > Thanks for any and all input.