Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refering to a closed form with code

Status
Not open for further replies.

amarkmac

IS-IT--Management
Aug 3, 2006
13
US
I know how to refer to controls and properties of an open form (e.g., Application.Forms![form.name].property ), but how about a form that isn't opened yet?

In my access project, I would like to make sure that the ServerFilter property is blank before opening the form--this property is occassionally left with data in it if there is a crash and the form is saved in an abnormal manner. I thought I could run this check once when the app is started. (I shouldn't have to worry about this once the app is developed, but currently it is a bit of a pain.)
 
The form has to be open before you can refer to it or any of it's parts. If need be, you could open it hidden, run whatever code you feel is necessary, then run your OpenForm command again, without the hidden attribute.


Randy
 
Why not add a little code to the Open or Load event of the form?
 
I really just want to be able to initialize the ServerFilter property on certain forms when the application starts up--not everytime the forms are opened. Randy700's suggestion let me accomplish this OK: I open the form hidden, clear the ServerFilter Property, then close and save the form. (I don't know for sure that this is working, however, since the app hasn't crashed yet today and left garbage behind in the ServerFilter property.)

In addition, since this is an ADP, the SQL server is being told how to fetch the data as the form is opening. If I use the OnOpen of OnLoad event to clear the ServerFilter property, I'm not sure that the server would then be able to service the data request. (I haven't really experimented with this, though, so I could be wrong.)
 
Hi!

Clear the property when the forms are closed.



Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
How are ya amarkmac . . .

The following function determines if a form is open (useful on its own):
Code:
[blue]Function IsOpenForm([purple][b]FormName[/b][/purple] As String) As Boolean
   
   If CurrentProject.AllForms(FormName).IsLoaded Then
      If Forms(FormName).CurrentView > 0 Then IsOpenForm = True
   End If

End Function[/blue]
You simply need to negate the above function for your purpose:
Code:
[blue]   IF Not IsOpenForm("[purple][b]FormName[/b][/purple]") Then
     [green]'Do This[/green]
   End If[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top