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

vb to check form is open

P: 3
What i wnat to do is check to see if a form is open before a new record can be entered.

If any of the forms are open ( Question3 Reason, Question 4 Reason and Question 9 Comments) I want an error message to be displayed saying something along the lines of

'Sorry you have 'form name here' open. Please click save on the form before continuing'

I started to write a macro which included the run code command but got stuck on the vb and also how to halt the macro if the result of the vb code is true (i was going down the route of form open = true, form not open = false)

any help or guidance would be much appreciated.

Thanks

Steven
Nov 21 '06 #1
Share this Question
Share on Google+
1 Reply


100+
P: 143
Courtesey of the Dev Ashish web site.

Pass the form name to the following function. Function will return True if form is open and False if it's not.

****** Code Start ********
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
'****** Code End ********
Nov 21 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.