On Click Refresh

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

Anne

Hi! I'm working on a database that has a form where the
records are entered and one form to search the records
form. What I would like to do is create some kind of VB
code to clear the search terms the user typed in after the
results come up, so that once the user closes the form
with the results, there is a blank search form so that
s/he can start over without having to close the entire
Access database to start over. Any ideas?
The search form is called "Search Main Records" and the
records form is called "View Main Records".
 
Try code along the following lines in the Unload event of
the "View Main Records" form.

If CurrentProject.AllForms("Search Main Records").IsLoaded Then
DoCmd.Close acForm, "Search Main Records"
End If
DoCmd.OpenForm "Search Main Records"

Hope This Helps
Gerald Stanley MCSD
 
This was good for getting rid of the text. I think my
problem is that I can't figure out how to erase the
previous search from the system's memory. It still acts as
if there is only one record and all the other records are
unsearchable. Is there some way to clear the form and
actually start over?
 
Please explain how the "View Main Records" form is opened
from the "Search Main Records" Form.

Gerald Stanley MCSD
 
I have a number of searchable fields in my general search
form: Title, Author, Date, Geography, Language, Format,
Sector, SearchTerms1, SearchTerms2, SearchTerms3,
SearchTerms4, SearchTerms5. Everthing after the date is a
drop-down menu, which may be screwing me up.


Private Sub cmdViewRecords_Click()
On Error GoTo Err_cmdViewRecords_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "View Main Records"

stLinkCriteria = "[Title] LIKE'" & Me![txtTitle] & "*'
AND [Author] LIKE'" & Me![txtAuthor] & "*'
AND [Date] LIKE'" & Me![txtDate] & "*'
AND [Geography] LIKE'" & Me![txtGeography] & "*'
AND [Language] LIKE'" & Me![txtLanguage] & "*'
AND [Format] LIKE'" & Me![txtFormat] & "*'
AND [Sector] LIKE'" & Me![txtSector] & "*'
AND [SearchTerms1] LIKE'" & Me![txtSearchTerms1] & "*'
AND [SearchTerms2] LIKE'" & Me![txtSearchTerms2] & "*'
AND [SearchTerms3] LIKE'" & Me![txtSearchTerms3] & "*'
AND [SearchTerms4] LIKE'" & Me![txtSearchTerms4] & "*'
AND [SearchTerms5] LIKE'" & Me![txtSearchTerms5] & "*'"
txtTitle.SetFocus
txtTitle.Text = ""
txtAuthor.SetFocus
txtAuthor.Text = ""
txtDate.SetFocus
txtDate.Text = ""
txtGeography.SetFocus
txtGeography.Text = ""
txtLanguage.SetFocus
txtLanguage.Text = ""
txtFormat.SetFocus
txtFormat.Text = ""
txtSector.SetFocus
txtSector.Text = ""
txtSearchTerms1.SetFocus
txtSearchTerms1.Text = ""
txtSearchTerms2.SetFocus
txtSearchTerms2.Text = ""
txtSearchTerms3.SetFocus
txtSearchTerms3.Text = ""
txtSearchTerms4.SetFocus
txtSearchTerms4.Text = ""
txtSearchTerms5.SetFocus
txtSearchTerms5.Text = ""
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdViewRecords_Click:
Exit Sub

Err_cmdViewRecords_Click:
MsgBox Err.Description
Resume Exit_cmdViewRecords_Click

End Sub
 
Anne said:
Hi! I'm working on a database that has a form where the
records are entered and one form to search the records
form. What I would like to do is create some kind of VB
code to clear the search terms the user typed in after the
results come up, so that once the user closes the form
with the results, there is a blank search form so that
s/he can start over without having to close the entire
Access database to start over. Any ideas?
The search form is called "Search Main Records" and the
records form is called "View Main Records".

I posted an answer this question in another newsgroup to which you also
posted it, as a separate message. That's called "multiposting", and
it's generally frowned on because others don't know what answers have
already been given, and so they duplicate the effort. Also it's harder
for you to keep track of the various replies, and it's harder for later
readers of the question, who may be looking for the same answer, to
learn what they need.

In most cases a single, well-chosen newsgroup will do. If your question
really is relevant to more than one newsgroup, the approved technique is
to "crosspost" it instead, by listing multiple newsgroups in the To: or
Newsgroups: line of a single message. If you do that, the message and
any replies will appear in all the listed newsgroups automatically,
which is beneficial to all concerned.
 
The filter that is applied to a form's recordset is
destroyed once the form has been unloaded. From the code
below, the new filter is being applied and you should be
getting the right set of rows that match your request form
when you open the "View Main Records" form.

Gerald Stanley MCSD
-----Original Message-----
I have a number of searchable fields in my general search
form: Title, Author, Date, Geography, Language, Format,
Sector, SearchTerms1, SearchTerms2, SearchTerms3,
SearchTerms4, SearchTerms5. Everthing after the date is a
drop-down menu, which may be screwing me up.


Private Sub cmdViewRecords_Click()
On Error GoTo Err_cmdViewRecords_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "View Main Records"

stLinkCriteria = "[Title] LIKE'" & Me![txtTitle] & "*'
AND [Author] LIKE'" & Me![txtAuthor] & "*'
AND [Date] LIKE'" & Me![txtDate] & "*'
AND [Geography] LIKE'" & Me![txtGeography] & "*'
AND [Language] LIKE'" & Me![txtLanguage] & "*'
AND [Format] LIKE'" & Me![txtFormat] & "*'
AND [Sector] LIKE'" & Me![txtSector] & "*'
AND [SearchTerms1] LIKE'" & Me![txtSearchTerms1] & "*'
AND [SearchTerms2] LIKE'" & Me![txtSearchTerms2] & "*'
AND [SearchTerms3] LIKE'" & Me![txtSearchTerms3] & "*'
AND [SearchTerms4] LIKE'" & Me![txtSearchTerms4] & "*'
AND [SearchTerms5] LIKE'" & Me![txtSearchTerms5] & "*'"
txtTitle.SetFocus
txtTitle.Text = ""
txtAuthor.SetFocus
txtAuthor.Text = ""
txtDate.SetFocus
txtDate.Text = ""
txtGeography.SetFocus
txtGeography.Text = ""
txtLanguage.SetFocus
txtLanguage.Text = ""
txtFormat.SetFocus
txtFormat.Text = ""
txtSector.SetFocus
txtSector.Text = ""
txtSearchTerms1.SetFocus
txtSearchTerms1.Text = ""
txtSearchTerms2.SetFocus
txtSearchTerms2.Text = ""
txtSearchTerms3.SetFocus
txtSearchTerms3.Text = ""
txtSearchTerms4.SetFocus
txtSearchTerms4.Text = ""
txtSearchTerms5.SetFocus
txtSearchTerms5.Text = ""
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdViewRecords_Click:
Exit Sub

Err_cmdViewRecords_Click:
MsgBox Err.Description
Resume Exit_cmdViewRecords_Click

End Sub

-----Original Message-----
Please explain how the "View Main Records" form is opened
from the "Search Main Records" Form.

Gerald Stanley MCSD
.
.
 
Back
Top