Query on Cbo not working

nfk

Registered User.
Local time
Yesterday, 18:30
Joined
Sep 11, 2014
Messages
117
When I create a Combobox that its supposed to grab info from a table and display a record depending on whats selected and I try to put something like on the Raw Source:

Code:
SELECT "tblFiles"."FileEntryNo", "tblFiles"."GroupCode"
FROM "tblFiles" 
WHERE "GroupCode" LIKE "EDU";

It will show only records for EDU

But if I try to put it like

Code:
SELECT "tblFiles"."FileEntryNo", "tblFiles"."GroupCode"
FROM "tblFiles" 
WHERE "GroupCode" LIKE "[Forms]![FrmTest]![Combo1]";

It wount display anything.

Cheers.
 
Probably because you have no records that have this exact text in their GroupCode field:

[Forms]![FrmTest]![Combo1]

Because of all those double quotes its looking for that value, not the value it contains. Where exactly is this SQL? Is it in a query or VBA?
 
Please show us the SQL statement used as the Row Source property of combo1
EDIT:
Sorry plog, didn't see your reply to this post.
 
I attach an image so you can see the source of the query...

this is an ADP file working with sql server 2005

I try many ways, with quotes, without, single doble quote, ampersand, brackets, etc... the only way it seem to work is if i actually input the value literally.

?

thanks for your help.
 

Attachments

  • thequery.jpg
    thequery.jpg
    89.3 KB · Views: 127
Is this the exact code you have in VBA?
"[Forms]![FrmTest]![Combo1]";

Because what I see in the pic is a form called FrmFiles and the Combo box selected is Combo198. I would think the code should be

WHERE "GroupCode" LIKE [Forms]![FrmFiles]![Combo198];

Most importantly, the bound column has to be the same column in which you're searching, which is currently the Group Code field according to your picture.
 
No, I just changed the values for the example... but they're alright, as I said the query works fine when the value is literal, but I want to input variable content, for example the value of a textbox.
 
I guess the question would be, How to send parameters or variables to a query using access 2010 ADP file. Since im working with sql server 2005 Im not able to use the typical Access syntax.
 
Have you tried:
SELECT "tblFiles"."FileEntryNo", "tblFiles"."GroupCode" FROM "tblFiles" WHERE "GroupCode" LIKE '" & [Forms]![FrmTest]![Combo1] & "';
 

Users who are viewing this thread

Back
Top Bottom