Re: Use of Flag field across all events

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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 (""))

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"stickandrock" <stickandrock@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9C6F1AF1-61E4-4BD4-933C-4FD7A5D9F689@xxxxxxxxxxxxxxxx
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
"Arvin Meyer [MVP]" wrote:

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
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

"stickandrock" <stickandrock@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:D9AA941C-AD47-40FF-BFE6-B6FB3EEF6609@xxxxxxxxxxxxxxxx
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.





.