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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering records in query from a form

Status
Not open for further replies.

Richey

Technical User
Aug 29, 2000
121
GB
Hi

From a form, I want the user to be able to send an xls/rtf file, something like

If Msgbox("Click Yes to send as a Text file." & Chr(13) & "Click No to send as a spreadsheet", vbYesNo + vbQuestion, "Send file") = vbYes Then
DoCmd.SendObject acSendQuery, "output", acFormatRTF, , , , "e-government report"
Else
DoCmd.SendObject acSendQuery, "output", acFormatXLS, , , , "e-government report"
End If

Output is the name of a query.
The problem I've got is that the user may want to filter the records on the form. When they click the command button to export, I want the query to be filtered also
any ideas?

Regards
Gareth
 
Reference the form fields in your query's criteria like this:

[Forms]![MyFormName]![MyControlName]

Between [Forms]![MyFormName]![MyControlName1] and [Forms]![MyFormName]![MyControlName2]

Like [Forms]![MyFormName]![MyControlName] & "*"

Any of those type of things would work.
Joe Miller
joe.miller@flotech.net
 
Joe

I probably didn't explain myself properly. The user would perform a search (using a standard QBF form i.e. exact copy of the form) which enables them to search on any of the fields, so the number of records returned will vary and I don't know which field they will search on?
I thought maybe I would need to somehow put the search results into a temporary table? and base the query on that?

Regards
Gareth
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top