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

Load search from Form into Query

Status
Not open for further replies.

JeffNolan1900

Technical User
Mar 21, 2007
26
0
0
US
I have a query called "QueryME"

I have a Form called "FormME"
Within that form, I have a search box called "SearchME"

When the user enters the word ' air ' into the search box, I want it to pull all types that have the word air in them and refresh the query.

The user should have the ability to do this repeatedly.

I tried putting this in the query criteria box:
[Forms]![frmXMLcreator]![ComboEntityName]

When the user clicks "Update Query" I guess the query reads the value from this text box.

It works one time. But the next time, it does not work.
It also will only pull up air, and not airport.

The code behind the button "Update Query" in my form, looks like this. All the button does is open the query. It's pretty standard.

Code:
Private Sub cmbUpdateQuery_Click()
On Error GoTo Err_cmbUpdateQuery_Click

    Dim stDocName As String
    
    stDocName = "QueryME"    
    DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_cmbGenerate_Click:
    Exit Sub

Err_cmbGenerate_Click:
    MsgBox Err.Description
    Resume Exit_cmbGenerate_Click
    
End Sub


errhhhh....
Thanks.
 
[small]
I tried putting this in the query criteria box:
[Forms]![frmXMLcreator]![ComboEntityName]
[/small]

I put this in the criteria box, under design mode of the query, for "Type" which is where I am searching.
 
How are ya JeffNolan1900 . . .

You need to have a look at the forms [blue]Filter[/blue] & [blue]Filter On[/blue] properties! . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
Thanks for the advice. I didn't think it would be necessary to use filters, I thought I could get around it. And it seems like, every time, right after I post in here, I figure it out. I think this place is good luck.

What I did was run a couple vba commands to close and then re-open the query, thus reloading the newly entered values entered into the search text boxes into the criteria within the query.

Here is the code for the button:
Code:
Private Sub cmbGenerate_Click()
    DoCmd.Close acQuery, "BentleyGeoQuery", acSaveNo
    DoCmd.OpenQuery "BentleyGeoQuery", acViewNormal, acReadOnly
End Sub

Then within my query design, for the field that the three different search criteria text boxes are related to:

Code:
     Like "*" & [Forms]![frmXMLcreator]![txtTYPE1] & "*"
or   Like "*" & [Forms]![frmXMLcreator]![txtTYPE2] & "*"
or   Like "*" & [Forms]![frmXMLcreator]![txtTYPE3] & "*"

This brings up the desired results. I figured I would post my fix, in case some other idiot like me comes along looking for a solution to an easy problem.

:)
 
nevermind.
That's not working now.
Though it was, I thought.
 
That is exactly what I was looking for ProgramError.
Perfect. I will have to look into that site further.
What an amazing resource, like this place...

You guys are the best.
jeff
 
Holy what a great resource! This is fantastic, Thanks for the tip, it has solved two of my problems. BTW, does anyone know how to make those great videos with the naration, those would be great for delivering my updates.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top