Can I check if a form is open in one of my query fields (1 Viewer)

atrium

Registered User.
Local time
Today, 22:51
Joined
May 13, 2014
Messages
348
If a particular form is loaded I want to use a data field from it in my query, if not the field will be left blank.

My code is
Code:
153: IIf (CurrentProject.AllForms("AddSTraceFrm").IsLoaded = True, DLookUp(" [SkipTraces]![TaxInvNo] ","SkipTraces"," [SkipTraces]![SkipTraceId] =  Forms![AddSTraceFrm]![STraceIdFld] ")," ")

As you can see I ask the question if the form is loaded, if so i want to do a lookup in the current record of the database used in the form to get the TaxInvNo and that is then the value for this field 153: in my query
If it's not loaded I want to put " " in the value for this field 153: in my query

Not sure if it can be done or this is syntax problems

Any help would be appreciated
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:51
Joined
Oct 29, 2018
Messages
21,358
You can create a function to return the value for your query. Or, maybe you could use a TempVar. Just a thought...
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 11:51
Joined
Sep 12, 2006
Messages
15,614
I use this isopen function

Code:
Function IsOpen(strName As String, Optional objtype As Integer = acForm)
     IsOpen = (SysCmd(acSysCmdGetObjectState, objtype, strName) <> 0)
End Function

objtypes constants are access constants
acQuery, acForm, acReport, acTable etc
acForm is the default

eg I use this to wait for a form to close, to avoid using dialog style forms.
Code:
while isopen("formname")
  doevents
wend
 

Users who are viewing this thread

Top Bottom