SQL consult from a Querie

IvaanGarciia

Member
Local time
Today, 03:46
Joined
Mar 5, 2020
Messages
37
Hi,

I got an Querie called RF Tracking Query, and I want to do a query from code liked to that query.
1585083045810.png


I'm trying to doing via the next code, in this case I want to bring back values, ingressing value on textbox and execute it from a button.

1585083107331.png


I got some txtbox linked to the RF Tracking query to view the info ,but for any reason not works, anyone knows what is my issue here.

regards,
 
Hi. If you take your SQL and put it in the query designer, does it work?
 
SELECT RF Tracking Query.[ID_asset], ...

When you name objects (Tables, Queries, etc) with non-alphanumeric characters you have to take extra steps when you reference them in queries and code. Because you have spaces in the query you are using you must bracket the entire query name, similar to what you did with the field name.
 
Just to add to plog's comments, having a query called *Enable";"Disable" is going to cause you MAJOR problems.
Whist there are no spaces, the query name contains several special characters * and " and ;.
Rename as e.g. qryEnableDisable
 
Just to add to plog's comments, having a query called *Enable";"Disable" is going to cause you MAJOR problems.
Whist there are no spaces, the query name contains several special characters * and " and ;.
Rename as e.g. qryEnableDisable
Enable/disble aren't in use I'm going to delete them.
 
First, as noted by plog, you need to bracket an object name that contains spaces, so you can NEVER use RF Tracking Query as such in SQL or various VBA functions. You have to use instead [RF Tracking Query] or you can rename it to RFTrackingQuery and then you wouldn't need the bracketing.


Once you get over that hurdle, my next concern is data types. What are the data types of ID_Asset and Num_Exp in that query you showed us? If they are strings, then you are OK and you have used correct syntax for that WHERE clause. If not, then you have the problem that the LIKE operator doesn't work on numbers so well and you are comparing numbers to strings.
 

Users who are viewing this thread

Back
Top Bottom