|
 |
access thread: Select Statement with a variable
Message #1 by "Jon" <jsaam@m...> on Wed, 12 Sep 2001 21:27:17
|
|
Hi all,
this is probably easy answer, but how would I go about using a select
statement to select something only if it matches the string value of a
variable. I can't seem to figure out the syntax of the quotes.
example:
Select * from [table1] Where rs2.fields.name = <variable>
<basically, I'm trying to compare two tables in the same database to find
out which fields are missing from one of them> <--- any ideas on how to do
that would be helpful also, although I think I have most of the code in
place already. The variable is actually the name of the first field from
the correct table -- I just want to check the second table to see if it
exisits, and if not, tell me :) simple eh? hehe
thanks in advance,
Jon
Message #2 by "Arjan van Huizen" <ajvhzn@p...> on Wed, 12 Sep 2001 23:06:14 +0200
|
|
Well, let's start. Make a new query with the Correct table 1 and the 2nd
table: Table2.
Create a join on the 2 matching fields on both tables. And set the correct
Join option(2 or 3) in the Join property window.
Place an IsNull criteria under the field from the table which have to be
compared for missing data. (you can even set this field to invisible)
Now you can run the query and when there's a missing field, the left field
is filled with data when the right field is blanc.
Is this what you mean?!
Good-luck
Arjan.
Holland.
----- Original Message -----
From: Jon <jsaam@m...>
To: Access <access@p...>
Sent: Wednesday, September 12, 2001 9:27 PM
Subject: [access] Select Statement with a variable
> Hi all,
>
> this is probably easy answer, but how would I go about using a select
> statement to select something only if it matches the string value of a
> variable. I can't seem to figure out the syntax of the quotes.
>
> example:
>
> Select * from [table1] Where rs2.fields.name = <variable>
>
> <basically, I'm trying to compare two tables in the same database to find
> out which fields are missing from one of them> <--- any ideas on how to do
> that would be helpful also, although I think I have most of the code in
> place already. The variable is actually the name of the first field from
> the correct table -- I just want to check the second table to see if it
> exisits, and if not, tell me :) simple eh? hehe
>
> thanks in advance,
>
> Jon
>
>
>
Message #3 by Paul Engel <pengel@s...> on Wed, 12 Sep 2001 17:17:32 -0400
|
|
The way I do this is to create a variable to hold the search string and
build it like so:
strQuery = "select * from table where field = '" & <variable> & "'"
Then, I insert strQuery where I would have normally put the select
statement.
-----Original Message-----
From: Jon [mailto:jsaam@m...]
Sent: Wednesday, September 12, 2001 9:27 PM
To: Access
Subject: [access] Select Statement with a variable
Hi all,
this is probably easy answer, but how would I go about using a select
statement to select something only if it matches the string value of a
variable. I can't seem to figure out the syntax of the quotes.
example:
Select * from [table1] Where rs2.fields.name = <variable>
<basically, I'm trying to compare two tables in the same database to find
out which fields are missing from one of them> <--- any ideas on how to do
that would be helpful also, although I think I have most of the code in
place already. The variable is actually the name of the first field from
the correct table -- I just want to check the second table to see if it
exisits, and if not, tell me :) simple eh? hehe
thanks in advance,
Jon
|
|
 |