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

Using SQL Query in Access

P: 2
I have a feeling that this is a silly question. But pls excuse me as i am a newbie and i have been beating abt this issue for 2 days and i have not been to solve it.

I made a form with 1 combo box, 1 buttom and a Grid DTC.

Now, for example. Taking the scenario of a car showroom.
By choosing the name of a brand or Company(like Honda) in the combo box and clicking on the button. I want to display every model(like Civic, Accord) that is available from that brand.

I wrote the query to do it in Queries part of access. It is working fine. But i am unable to write that query in the VB window that pops up when i go to the Events in the property of button.

Pls guide me
Thanks
Nov 17 '06 #1
Share this Question
Share on Google+
6 Replies


NeoPa
Expert Mod 15k+
P: 31,494
Please post in here what you have in the properties of the form for :
Record Source
Filter
Order by
Allow Filters

Also, if the record source is the name of a query, then post the SQL of that query (Design view of query then select SQL View from the View menu).
Nov 17 '06 #2

100+
P: 143
If it's working as a named query, why change it to SQL? DoCmd.OpenQuery "myquery" will work just as well.
Nov 17 '06 #3

NeoPa
Expert Mod 15k+
P: 31,494
I wasn't suggesting that anyone change the query to SQL.
Merely to change the view of an existing query to show the embedded SQL in order to post it in here.
Nov 17 '06 #4

MMcCarthy
Expert Mod 10K+
P: 14,534
I have a feeling that this is a silly question. But pls excuse me as i am a newbie and i have been beating abt this issue for 2 days and i have not been to solve it.

I made a form with 1 combo box, 1 buttom and a Grid DTC.

Now, for example. Taking the scenario of a car showroom.
By choosing the name of a brand or Company(like Honda) in the combo box and clicking on the button. I want to display every model(like Civic, Accord) that is available from that brand.

I wrote the query to do it in Queries part of access. It is working fine. But i am unable to write that query in the VB window that pops up when i go to the Events in the property of button.

Pls guide me
Thanks
Further to what NeoPa said:

Can you supply the following ...

1. The name of the form. I assume the record source of the form is the aforementioned query. If you open the query in design view and then change the view to sql you can copy and paste the full sql statement here.
2. The system name of the combobox control and the row source of the combo box. This might just be a value list like "Honda";"Nissan";..etc.
Or it might be based on a sql query or a table.
3. The system name of the command button.
4. 'a Grid DTC' - are you talking about a datagrid or a subform in datasheet view?

With this information we can give you the VBA code to use in the button click event. Essentially the options are to set a filter or change the record source of the form dynamically. We will have a better idea which option to use if you can provide the above information.

Mary
Nov 17 '06 #5

P: 2
First off, i am extremly sorry for thr delay in replying.
Grid DTC is a datagrid. I dragged it from the tool bar menu. i named the button "btnList"
The query in perfectly working. When i run it in the query section. BUt in the form, i dont know how to implement it.
If i select honda and click the button. I want the list of all the honda cars in the data grid
Nov 18 '06 #6

NeoPa
Expert Mod 15k+
P: 31,494
Sreenadh,

Can you revisit my earlier post and find the information for us please.
Then we can start to look at this seriously. At the moment we're all a little in the dark.
Nov 18 '06 #7

Post your reply

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