SQL consult from a Querie (1 Viewer)

IvaanGarciia

Member
Local time
Yesterday, 17:48
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,
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 17:48
Joined
Oct 29, 2018
Messages
21,453
Hi. If you take your SQL and put it in the query designer, does it work?
 

plog

Banishment Pending
Local time
Yesterday, 19:48
Joined
May 11, 2011
Messages
11,638
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.
 

isladogs

MVP / VIP
Local time
Today, 01:48
Joined
Jan 14, 2017
Messages
18,209
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
 

IvaanGarciia

Member
Local time
Yesterday, 17:48
Joined
Mar 5, 2020
Messages
37
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.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 19:48
Joined
Feb 28, 2001
Messages
27,138
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

Top Bottom