Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / January 2007

Tip: Looking for answers? Try searching our database.

Use of Flag field across all events

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
stickandrock - 14 Jan 2007 02:43 GMT
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.
Arvin Meyer [MVP] - 14 Jan 2007 03:43 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.