By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,847 Members | 3,094 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,847 IT Pros & Developers. It's quick & easy.

Run a query from a FORM and display results in same FORM???

matrekz42
P: 37
Good afternoon folks,

I currently have a button in a form to run a query and I want to display the results of the query in the same form where I have the button. How can I go about this? I've tried subforms, and Recordset but no luck... All help is greatly apprciated. Thank you in advance.
Jan 29 '08 #1
Share this Question
Share on Google+
5 Replies


100+
P: 365
if you are displaying your info in a listbox or a subform then you can update the details when you press the button

for example

on the buttons on click event you can type

[forms]![frmForm]![Listbox1].rowsource = "SQL" / queryname

and similarly for the subform
Jan 29 '08 #2

matrekz42
P: 37
if you are displaying your info in a listbox or a subform then you can update the details when you press the button

for example

on the buttons on click event you can type

[forms]![frmForm]![Listbox1].rowsource = "SQL" / queryname

and similarly for the subform

OK, I have a textbox and the user enters a number an it searches for a record and it displays the results in a qsel view. I don't have a listbox... I'm going crazy!!!! lol. What should I do?
Jan 29 '08 #3

100+
P: 365
qsel??

assign an after update event upon the textbox so that when the user hits enter it runs the code.
Jan 29 '08 #4

matrekz42
P: 37
qsel??

assign an after update event upon the textbox so that when the user hits enter it runs the code.

qsel = SELECT Query

Sorry... I tried doing this but it doesnt work, overall what I'm trying to achieve is text box where the user inputs the data and the results of the query ran appear in like another type of object or box right under in the same form, would i need to creat two text boxes? I tried the code and changed the name and rowsource, but no luck...
Jan 30 '08 #5

100+
P: 365
I asume you have the txtbox referenced in your query?

as in SELECT blah FROM blahblah WHERE blah = [forms]![frmForm]![txtbox1]

if you just want to display the data then i would use a list box (cos they look neat)

and you would use the sql(you can use the query builder) in the row source

in VB on the after update command (of the textbox) you can reset the row source of the list box

as

me.listbox1.rowsource = "SELECT blah FROM blah......................"

that should work (each time you update the textbox it will use the data and rerun the query)

Dan
Jan 30 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.