quick question about sql queries

jlabre01

Registered User.
Local time
Today, 05:50
Joined
May 26, 2008
Messages
62
Hi,

I just wanted to know what the proper format was for setting the control source for a text box to an sql statement was?

jlabre01
 
Are you trying to insert a single value from a table field in the textbox?
 
yes, i'm searching for one value
 
Then using dlookup() maybe an option - ?
 
well the query needs to check a couple things, to return the value
 
You can do that with a domain function like dlookup().
 
Just out of curiosity I tried putting a sql statement in for the control source in the properties and using vba and couldn't get it to work. That's the essence of a domain function...
 
The closest you'll get to a SQL source in a controlsource if a function which returns a value (much like the Domain Lookup does).
For example
=CurrentDb.OpenRecordset("SELECT FieldName FROM TableName WHERE FieldX = 1")(0)

Obviously untidy and unadvisable. Just re-enforcing a point really.
(And certain expressions are all over the place in Acc2007).

You'd have to write your own SQL statement resolving function to have real control over the execution.
But alot is possible with just the humble DLookup too - as already mentioned.
 

Users who are viewing this thread

Back
Top Bottom