I'm getting the error below when I'm trying to use a Combobox Value in my access query. I've done this in design view. In the criteria field in the referenced column in my query I've placed the below filter. The idea is that when I change the combobox the event triggers a procedure which calls the query. That query incorporates the value from Combobox50. I've also placed the code below as well.
Not sure if my syntax is wrong. Can anybody help. Thanks
[forms]![form1]![combo2] 'have placed this in criteria field
Error below.
'Invalid SQL Statement; Expected Delete, Insert, Procedure, select or Update'
Private Sub Combo2_AfterUpdate() Dim rst1 As Recordset Set rst1 = New ADODB.Recordset rst1.Open "RefLookup", CurrentProject.Connection ' "RefLookup" is the query name. Form_Form1.Text37.Value = rst1.Fields(1) End Sub
Last edited by danny2000; 12-04-2010 at 09:41 PM.
What happens when you run the query manually? Here is a video on creating a search form linked to a query. Does this help you?
http://www.datapigtechnologies.com/f...earchform.html
Alan
Alan
Click the * below to say thanks.
Database Principles
Pivot Table Tips
Good Excel Video Tutorials
Sumifs or SumProduct
DataPig Access Tutorials
MS Query Tutorial
Worst Pie Chart Ever?
Thanks for that. When I run the query manually a parameter box comes up and it works on its own. There's something wrong with the fact that I've referenced the combobox in the query criteria. The tutorial is great but I still get the same error.
Are you able to post your db with some sample data so that we can look at it and see what the issues are.
Alan
Alan
Click the * below to say thanks.
Database Principles
Pivot Table Tips
Good Excel Video Tutorials
Sumifs or SumProduct
DataPig Access Tutorials
MS Query Tutorial
Worst Pie Chart Ever?
No worries.
I've attached an example. All you do is select the car type in the combobox and it should give you the colour in the textbox. Though I get the error.
thanks in advance.
Danny2000
Last edited by danny2000; 11-24-2010 at 03:35 AM. Reason: Adding attachment.
Danny,
I have changed your form as attached in the database. I deleted your after update event and made your control source for the car-make a query. Look at the properties for the two form controls. There was no need for any VBA to make this work. You can delete the query you have as it is not needed.
Alan
Alan
Click the * below to say thanks.
Database Principles
Pivot Table Tips
Good Excel Video Tutorials
Sumifs or SumProduct
DataPig Access Tutorials
MS Query Tutorial
Worst Pie Chart Ever?
Thanks very much for your effort. I really appreciate it.
I've tried to make use of the combobox in the query criteria in this case as vba can be used when
using DAO. In this case I'm using ADO and it doesn't seem to handle it at all. I've only just discovered this. I'm sure there's a way. It's just a smaller part of a big picture and I would like to try to make it work if at all possible. Your solution is a good one though and I'll definitely keep that in mind.
Thanks for your response
Danny2000
Thanks again for your replies.
The problem above accurs because you can't use a Query name as the 'Source' when opening a Recordset. Ultimately this is why it is creating an error.
Danny2000
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks