On Click Refresh

  • Thread starter Thread starter Anne
  • Start date Start date
A

Anne

Hi! I'm working on a database where I have one form,
called "View Main Records", that houses the information
itself. I also have a "Search Main Records" form that
allows the user to search multiple fields and then the
corresponding records come up from the "View Main Records"
form.
What I need is a way to refresh the "Search Main Records"
form as soon as the results come up in "View Main
Records." This would be some kind of VB code to clear the
form so that after the user browses the results and closes
the other form, s/he could begin a new search without
having to close the search form. Right now I have
Me.Refresh, but I still have to close the search form to
start over. Any ideas?
 
Anne said:
Hi! I'm working on a database where I have one form,
called "View Main Records", that houses the information
itself. I also have a "Search Main Records" form that
allows the user to search multiple fields and then the
corresponding records come up from the "View Main Records"
form.
What I need is a way to refresh the "Search Main Records"
form as soon as the results come up in "View Main
Records." This would be some kind of VB code to clear the
form so that after the user browses the results and closes
the other form, s/he could begin a new search without
having to close the search form. Right now I have
Me.Refresh, but I still have to close the search form to
start over. Any ideas?

From the sound of it, the "Search Main Records" form is unbound, since
it's just serving as a means of generating a filter for the "View Main
Records" form. Therefore, Refresh won't have any effect. I think you
could use code like this, possibly executed by a command button on the
form:

' *** WARNING: AIR CODE ***

Dim ctl As Access.Control

' Disable error-checking, to avoid errors with
' non-data controls.
On Error Resume Next

For Each ctl In Me.Controls

If Len(ctl.DefaultValue) > 0 Then
ctl.Value = Eval(ctl.DefaultValue)
Else
ctl.Value = Null
End If

Next ctl
 
Back
Top