R
rdemyan via AccessMonster.com
I have to make use of data in another system. The data is imported into my
app and stored in a table. Unfortunately there is no primary key. Only two
fields out of about 15 are required and these two do not constitute a unique
key.
I need to be able to select records from the table based on almost all of the
fields. In 99% of the cases this will yield a unique row but there will be
exceptions.
I'm having trouble with how to use Nz in an SQL statement to be used in code.
I have the following (this is abbreviated, but shows the issues). It seems
to work, but I want to confirm that I am doing it the correct way.
strSQL = "SELECT * FROM [TABLEA] WHERE BUILDING_ID = '" & rsOLD("BUILDING_ID")
& "'" & _
" AND Nz(USER_ID,'') = '" & Nz(rsOLD("USER_ID")) & "' AND Nz(AREA,0)
= " & Nz(rsOLD("AREA"), 0) & _
" AND TIME_STAMP = #" & Me.Download_Date & "# ORDER BY BUILDING_ID
ASC;"
I severely shortened this but it contains the elements of what I need to
confirm (hopefully I didn't type in any syntax errors).
The issue I have is if USER_ID or AREA are null in the table. I still need
to get that record and I want to make sure that my syntax is correct. rsOLD
is a recordset that is created prior to the code reaching this SQL statement.
Thanks.
app and stored in a table. Unfortunately there is no primary key. Only two
fields out of about 15 are required and these two do not constitute a unique
key.
I need to be able to select records from the table based on almost all of the
fields. In 99% of the cases this will yield a unique row but there will be
exceptions.
I'm having trouble with how to use Nz in an SQL statement to be used in code.
I have the following (this is abbreviated, but shows the issues). It seems
to work, but I want to confirm that I am doing it the correct way.
strSQL = "SELECT * FROM [TABLEA] WHERE BUILDING_ID = '" & rsOLD("BUILDING_ID")
& "'" & _
" AND Nz(USER_ID,'') = '" & Nz(rsOLD("USER_ID")) & "' AND Nz(AREA,0)
= " & Nz(rsOLD("AREA"), 0) & _
" AND TIME_STAMP = #" & Me.Download_Date & "# ORDER BY BUILDING_ID
ASC;"
I severely shortened this but it contains the elements of what I need to
confirm (hopefully I didn't type in any syntax errors).
The issue I have is if USER_ID or AREA are null in the table. I still need
to get that record and I want to make sure that my syntax is correct. rsOLD
is a recordset that is created prior to the code reaching this SQL statement.
Thanks.