Simple: Write to a table?

mlopes1

Registered User.
Local time
Today, 19:05
Joined
Sep 4, 2002
Messages
76
I have a control button that opens FormA. On the "OnClick" event I want to :

1. Check the value of a variable named YesOpen in a table called FormOpen.

2. If YesOpen = 0 then, open FormA and then write to the table FormOpen to change the value of the Variable YesOpen to 1.
Else if YesOpen <> 0 then...
Msgbox("Form already open")
end if

I'm unfamiliar with how to code this. Basically I just want a table that will keep track of if a form is open. Any ideas?

Thanks as always,

Marco
 
Do not use a table for this...

use the following code:

Code:
Option Compare Database
Option Explicit

 Function IsLoaded(strFrmName As String) As Boolean
    
    '  Determines if a form is loaded.
    
    Const conFormDesign = 0
    Dim intX As Integer
    
    IsLoaded = False
    For intX = 0 To Forms.Count - 1
        If Forms(intX).formname = strFrmName Then
            If Forms(intX).CurrentView <> conFormDesign Then
                IsLoaded = True
                Exit Function  ' Quit function once form has been found.
            End If
        End If
    Next

End Function

To check if a form is open just do this:

Code:
If(IsLoaded("MyFrm")) then
  'its open
else
  'its not open
end if
 
Re: Re: Simple: Write to a table?

I'd place this in a module BTW, just in case you need to use it anywhere else within your application.
 
Hey Jon,

That is definitely a better solution and I think that I have put it in correctly. However, I get this error "Expected variable or procedure, not module" when I tried running the code:

If (IsLoaded("Lookup")) Then
MsgBox ("...")
Else
MsgBox("AAA")
End If

I named my module IsLoaded and it accepts the form name as a variable just like you set up.

Any ideas?

Thanks again.

Marco
 
OK, got that to work. Thanks a ton. Now a follow-up:

can this be modified for a multi-user database? I tried inserting it, and it does not recognize if a second user on another PC has the form open.

Thanks again,

Marco
 
mlopes1 said:
OK, got that to work. Thanks a ton. Now a follow-up:

can this be modified for a multi-user database? I tried inserting it, and it does not recognize if a second user on another PC has the form open.

Thanks again,

Marco

Yes it does work for multi user that has nothing to do with it...its a module..make sure that module is available to that other use.r
 

Users who are viewing this thread

Back
Top Bottom