Run Query In (1 Viewer)

Diamond-Leopard

Registered User.
Local time
Today, 15:03
Joined
Oct 30, 2018
Messages
26
So I have a very simple query that does a quick search through one of my tables for the word entered into a text box on a form... at the moment I have a button under the text box which says "Run Query" and this pops up the query with my search results and that is all dandy.

What I would like is the search results to be in another large text box under the input text box which would display the results .. so instead of a new window with the query on it.. I would like the querey to be displayed in the text box as soon as the input text box is changed.

So something like

Private Sub txtInputBox_AfterUpdate()

txtSearchResults.value = 'Resultsofquery'

End Sub

Any Idea?

Thanks Guys
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 00:03
Joined
Jan 20, 2009
Messages
12,851
Textbox is not really suited to this task. You could use a subform structure.
 

isladogs

MVP / VIP
Local time
Today, 15:03
Joined
Jan 14, 2017
Messages
18,209
That won't work unless the query output only has one record and one field.
Instead create a subform with the query as it's record source.
Add the subform to your main form and make it hidden by default.
When you click the button make the subform visible to show your results
 

Diamond-Leopard

Registered User.
Local time
Today, 15:03
Joined
Oct 30, 2018
Messages
26
Ok guys so I now have a subform inside that form and the subform is made visable when the button is clicked but the query pops up empty? Do i need like a refresh code? like something to re-run the query with the new word in the text box?
 

Diamond-Leopard

Registered User.
Local time
Today, 15:03
Joined
Oct 30, 2018
Messages
26
Sweeet Guys I just did a requery.Queryname and that has sorted it sweet!!

I wonder now If I can have it only pop up if it shows a search result?

If it finds nothing can I make it stay hidden?
 

isladogs

MVP / VIP
Local time
Today, 15:03
Joined
Jan 14, 2017
Messages
18,209
Ah...never satisfied :)

You could add something like

Code:
if DCount("*","YourQueryName")>0 Then
Me.subform.visible =true
End if
 

Diamond-Leopard

Registered User.
Local time
Today, 15:03
Joined
Oct 30, 2018
Messages
26
I did it,

It worked perfectly!

You are truly a god to me :D

Thank you very much
 

Users who are viewing this thread

Top Bottom