queries in forms

virgosam20

Registered User.
Local time
Today, 00:32
Joined
Jul 7, 2007
Messages
49
Is there any way to make a form that will allow me to select the query which i wish to use, rather than just having a different button that will execute each query individually?
 
There sure is.

Here's a real easy way if you name your queries with a prefix like: qry_

You can set the rowsource of a combo box or list box this:

SELECT MsysObjects.Name, Mid([Name],5) AS QueryName
FROM MsysObjects
WHERE (((Left([Name],4))="qry_"))
ORDER BY MsysObjects.Name;



And then you can set the column count to 2 and set the column widths to 0";1.5" which will then show the stripped name (without the qry_ part)

Then in say the AfterUpdate event for a combo box or a double-click event for the list box you can put:

DoCmd.OpenQuery Me.YourComboOrListBoxName


Now, that being said, I would highly suggest that you use forms for user interaction and not queries or tables directly themselves. You have much more control over things if you do than if you let them access things directly.
 
I'm afraid I don't really understand this. sorry.
 
Here's a sample for you. Hopefully this will help.

Look in the database window and you'll see 3 queries there, but only 2 show up in the list box on the form. Rename the third one (the one named ProductInfo) to something like qry_ProductInfo and see that when you reopen the form it will now be in the list.
 

Attachments

Um.... something has happend and i dont know how it did!

On one of my forms, which i haven't done anything to in a while, wont let me enter any new information. The computer just makes a noise when i try to type in a text box.

I don't know whether i have changed something accidentally, but i have even tried to create a new form using the same table and the same thing happened again.

Any ideas...?
 
On one of my forms, which i haven't done anything to in a while, wont let me enter any new information
You might have changed the form properties on accident. Take a look at "AllowEdits", "AllowDeletions", "AllowAdditions", any "Lock" properties and the "Enabled" line....
 

Users who are viewing this thread

Back
Top Bottom