469,642 Members | 1,279 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,642 developers. It's quick & easy.

vb to check form is open

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.


Nov 21 '06 #1
1 9561
143 100+
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.

Similar topics

9 posts views Thread by Shyguy | last post: by
30 posts views Thread by S. van Beek | last post: by
9 posts views Thread by KelsMckin | last post: by
5 posts views Thread by Andrew Meador | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.