Refreshing Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a popup form (form one) that sets the criteria for
a parameter query. When the user enters criteria in the
text boxes and selects OK on the popup form, two things
happen: another form opens (form two) which has the
results of the query as the data source and the visible
property of the popup is set to false. When the user
selects find on form two, I set the visible property for
the popup form to true and allow the user to enter new
criteria. I need to know how to do two things: How do I
rerun (refresh) the form (or query) so that form two will
reflect the new criteria and How do I test for an open
form, so I do not open form two again, I just want to
refresh it? Thanks.
 
I am not an expert but in my opinion (you may or may not choose to use) you
can include :
DoCmd.Close
under the OnClick Event of the "Find" control on your form two, after the
code that sets the Visible property of your Form One. This will ensure that
your form 2 will always have the latest query results since it is freshly
opened, and you do not have to check if the form is open or not.

Here you will find an answer on how to update "all forms" but read the
begining comments http://www.mvps.org/access/forms/frm0056.htm
Answer to your second question is here:
http://www.mvps.org/access/forms/frm0002.htm
But if you need the answer immediately, here is what it contains:
By Dev Ashish
'****** 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 ********I hope it helps.

Alp
 
If you used A2K or later, you can use the AllForms
collection to check if the Form2 is loaded. I assume that
the RecordSource Query of Form2 is a parametrised Query
with the Parameters getting the values from Form1. In
this case, you can use code like:

If CurrentProject.AllForms("Form2").IsLoaded = True Then
' Form2 is loaded
Forms!From2.Requery
Else
' Form2 is not loaded
DoCmd.OpenForm "Form2" ' Aruments if required.
End If

If you use A97, you need to copy the IsLoaded() function
from NorthWind database and replace the criteria for the
If statement similarly.

HTH
Van T. Dinh
MVP (Access)
 
Back
Top