How Can I have a listbox let users choose what query to run? (1 Viewer)

JTQ911

Registered User.
Local time
Today, 16:46
Joined
Jul 26, 2007
Messages
83
I want to have users be able to choose query "x" "y" or "z" from a listbox. Upon selection of query "x" "y" or "z" from the listbox, I want the query to run? I want to run this query from form "RunQueries" Does anyone know how I can do this? Thank you in advance for any suggestions, I appreciate all the help I can get
 
I want to have users be able to choose query "x" "y" or "z" from a listbox.
To do this, write this in the Listbox rowsource:
Code:
SELECT MSysObjects.Name

   FROM MSysObjects

      WHERE MSysObjects.Name NOT LIKE "~*" AND
         MSysObjects.Type = 5;
Upon selection of query "x" "y" or "z" from the listbox, I want the query to run?
So, then put an Openquery command on one of the Listbox events. If you want the query to open when the user selects a choice, then use the AfterUpdate event of the box, like this:
Code:
Pivate Sub MyListBox_AfterUpdate()

  docmd.openquery Me.MyListBoxName, [I]Other Specs (if you want them listed)[/I]

End Sub
I want to run this query from form "RunQueries"
Not sure I understand you on this one...
 
Filling the listbox worked excellent, but I am having trouble in doing the openquery after update thing. If my listbox name is List8, what is the exact code I should copy and paste into the expression after update event line. I apologize for my stupidity.
 
Filling the listbox worked excellent, but I am having trouble in doing the openquery after update thing. If my listbox name is List8, what is the exact code I should copy and paste into the expression after update event line. I apologize for my stupidity.
Code:
DoCmd.OpenQuery me.list8, acViewNormal, acReadOnly (or "acEdit", or "acAdd" instead)

Don't you have an intellisense dropdown when you're writing code? Or have you never written code before? If you haven't, you should try practicing, and seeing what options the dropdown gives you in various situations, so you learn what properties, actions, etc.. follow what objects, commands, etc.
 
Thanks for the help. I have never written code before in vba/sql. I am a college student doing an engineering internship for a company and over winter break one of my projects is to create a database (???!) for them. I like the challenge and when I have free time I'm def going to try and learn more about programming in access. i am seeing now how much being able to program in access allows much more creativity when it comes to building databases.
 
Still no luck, I keep getting NO Do.cmd macro, or invalid syntax.....
 
post the EXACT code you are using. Post every line that is in the event sub
 
To give you a reference, I have just tested this with a query of mine.

Here is the code that works fine for me:
Code:
Private Sub CommandButton2_Click()

  DoCmd.OpenQuery Me.Combo0, acViewNormal, acReadOnly

End Sub
 
Private Sub CommandButton2_Click()

DoCmd.OpenQuery Me.Combo12, acViewNormal, acReadOnly

End Sub




I am using a combo box, whose name is Combo12 when i put that in the event line on click, or after update, i get the error message : you may have entered an operator without an operand.
 
Oh man finally got it, i entered in the one line in the actual code itself instead of tryin to insert it into the properties box......thank you so much for your help, i cant tahnk you enough
 
Oh man finally got it, i entered in the one line in the actual code itself instead of tryin to insert it into the properties box......thank you so much for your help, i cant tahnk you enough
[Laugh] :) OK then! Good luck to you!
 

Users who are viewing this thread

Back
Top Bottom