By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,225 Members | 1,430 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,225 IT Pros & Developers. It's quick & easy.

Code to check if form is open

P: n/a
Hi,

I've got an input form (frmInput) that can be accessed in two ways.
A combobox on this form either gets filled in by a selection on an already
opened form (frmBasic), or one can input a value manually after opening the
frmInput directly.
Is there a way in VBA I can detect if the frmInput is opened based on a
selection on frmBasic or if the frmInput is opened as stand alone?
I suppose something in the onload event of frmInput that checks IF frmBasic
is open THEN the combobox has a value based on a field in the open frmBasic
ELSE the combobox is NULL.
No idea what the code would look like in this case.
All help is welcome.

Thx.
Feb 14 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Eagle wrote:
Hi,

I've got an input form (frmInput) that can be accessed in two ways.
A combobox on this form either gets filled in by a selection on an
already opened form (frmBasic), or one can input a value manually
after opening the frmInput directly.
Is there a way in VBA I can detect if the frmInput is opened based on
a selection on frmBasic or if the frmInput is opened as stand alone?
I suppose something in the onload event of frmInput that checks IF
frmBasic is open THEN the combobox has a value based on a field in
the open frmBasic ELSE the combobox is NULL.
No idea what the code would look like in this case.
All help is welcome.

Thx.


To detect if frmBasic is open you could use this function;

Function fIsLoaded(ByVal strFormName As String) As Integer
'Returns a 0 if form is not open or a -1 if Open
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> 0 Then
If Forms(strFormName).CurrentView <> 0 Then
fIsLoaded = True
End If
End If
End Function
Then call it like this;

If fIsLoaded("frmBasic") = True Then
'whatever code you like
End if
Feb 14 '06 #2

P: n/a

"Deano" <de***@mailinator.com> schreef in bericht
news:43**********************@ptn-nntp-reader01.plus.net...
To detect if frmBasic is open you could use this function;

Function fIsLoaded(ByVal strFormName As String) As Integer
'Returns a 0 if form is not open or a -1 if Open
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> 0 Then
If Forms(strFormName).CurrentView <> 0 Then
fIsLoaded = True
End If
End If
End Function
Then call it like this;

If fIsLoaded("frmBasic") = True Then
'whatever code you like
End if


Thanks Deano!
Will give it a go and will get back to you if this does the trick.
Feb 14 '06 #3

P: n/a
CurrentProject.AllForms("frmBasic").IsLoaded

Feb 15 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.