Hi All!
I'm kind of stuck! I have an Access database that is being queried via a series of VB scripts and it is the last one that gives details where I am occasionally having a problem. There are two tables between which a comparison is made on two of the fields. One table, the main one with the majority of the information, is for a specific record ID, while the other has about fifteen records where it needs to choose a match on one field. The problem is, occasionally there is not a match, such as when a new record is added to the main table but before it has a match in the second. Other times it is just a plain typo that causes the problem and, since we do not provide the data ourselves, we can only proof read it to a point when it comes to us.
When I try to catch the problem with if statements, I need to use an rs but when it doesn't exist it still crashes. Originally is was in the sql statement itself where the match was being made, which crashed too if there wasn't a match. I thought by moving it outside the sql statement, there would be a better chance of catching the error! It is the fact that I seem to need an dpval = rs("dp" in the if statement that crashes it when there isn't a match! Any help is appreciated as I've been pulling my hair out over this one!
Don
[tt]sql = "SELECT [HELPSCC ORIGINATING AGENCY].[Data Provider] AS [DP], agency.[Originating Agency] AS [OA] FROM [HELPSCC ORIGINATING AGENCY], agency WHERE [AGENCY].[ID] = " & AID
set rs = Server.CreateObject("ADODB.Recordset"
rs.Open sql, conn
dpval = rs("DP"
oaval = rs("OA"
if dpval <> oaval then
rs.MoveFirst
while not rs.eof and dpval <> oaval
if dpval <> oaval then
rs.movenext
dpval = rs("dp"
end if
rs.MoveNext
wend[/tt] [sig]<p>Don<br><a href=mailto:don@ctagroup.org>don@ctagroup.org</a><br><a href= - Health & Human Services Database</a><br>Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)[/sig]
I'm kind of stuck! I have an Access database that is being queried via a series of VB scripts and it is the last one that gives details where I am occasionally having a problem. There are two tables between which a comparison is made on two of the fields. One table, the main one with the majority of the information, is for a specific record ID, while the other has about fifteen records where it needs to choose a match on one field. The problem is, occasionally there is not a match, such as when a new record is added to the main table but before it has a match in the second. Other times it is just a plain typo that causes the problem and, since we do not provide the data ourselves, we can only proof read it to a point when it comes to us.
When I try to catch the problem with if statements, I need to use an rs but when it doesn't exist it still crashes. Originally is was in the sql statement itself where the match was being made, which crashed too if there wasn't a match. I thought by moving it outside the sql statement, there would be a better chance of catching the error! It is the fact that I seem to need an dpval = rs("dp" in the if statement that crashes it when there isn't a match! Any help is appreciated as I've been pulling my hair out over this one!
Don
[tt]sql = "SELECT [HELPSCC ORIGINATING AGENCY].[Data Provider] AS [DP], agency.[Originating Agency] AS [OA] FROM [HELPSCC ORIGINATING AGENCY], agency WHERE [AGENCY].[ID] = " & AID
set rs = Server.CreateObject("ADODB.Recordset"
rs.Open sql, conn
dpval = rs("DP"
oaval = rs("OA"
if dpval <> oaval then
rs.MoveFirst
while not rs.eof and dpval <> oaval
if dpval <> oaval then
rs.movenext
dpval = rs("dp"
end if
rs.MoveNext
wend[/tt] [sig]<p>Don<br><a href=mailto:don@ctagroup.org>don@ctagroup.org</a><br><a href= - Health & Human Services Database</a><br>Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)[/sig]