I have an SQL database with a table set up similar to:
id | identifier | activityNumber | locationID | activity_date
The locationID field can repeat, so it is possible to have something like:
1 | 200 | 1 | 3 | 4/11/2004
....
5 | 200 | 3 | 3 | 4/15/2004
6 | 200 | 2 | 2 | 4/15/2004
....
10 | 200 | 3 | 2 | 5/3/2004
11 | 200 | 2 | 4 | 5/3/2004
With the above data, I'd want to see where "200" was (locationID) on 5/1/2004
I've gotten as far as:
strSQL = "SELECT * FROM this_table WHERE identifier = '200';"
Set objRS = objConn.Execute(strSQL)
If objRS.EOF Or objRS.BOF Then
'Do whatever I want it to do if nothing is found
Else
objRS.MoveFirst
Do While Not objRS.EOF Or objRS.BOF
iActivityNumber = objRS.Fields("activityNumber")
iLocationID = objRS.Fields("locationid")
vActivityDate = objRS.Fields("activity_date")
If iActivityNumber = 1 Or iActivityNumber = 2 Then
'Check the date
If vActivityDate = "4/1/2004" Or vActivity < "4/1/2004" Then
'I want to use this ONE entry and stop checking
Else
'Do nothing and keep checking
End If
Else
'Don't do anything
End If
objRS.MoveNext
Loop
End If
I do I stop the checking this identifier and go on to the next one? The identifier is being pulled and used as a variable right before this, and there are literally hundreds of them.
id | identifier | activityNumber | locationID | activity_date
The locationID field can repeat, so it is possible to have something like:
1 | 200 | 1 | 3 | 4/11/2004
....
5 | 200 | 3 | 3 | 4/15/2004
6 | 200 | 2 | 2 | 4/15/2004
....
10 | 200 | 3 | 2 | 5/3/2004
11 | 200 | 2 | 4 | 5/3/2004
With the above data, I'd want to see where "200" was (locationID) on 5/1/2004
I've gotten as far as:
strSQL = "SELECT * FROM this_table WHERE identifier = '200';"
Set objRS = objConn.Execute(strSQL)
If objRS.EOF Or objRS.BOF Then
'Do whatever I want it to do if nothing is found
Else
objRS.MoveFirst
Do While Not objRS.EOF Or objRS.BOF
iActivityNumber = objRS.Fields("activityNumber")
iLocationID = objRS.Fields("locationid")
vActivityDate = objRS.Fields("activity_date")
If iActivityNumber = 1 Or iActivityNumber = 2 Then
'Check the date
If vActivityDate = "4/1/2004" Or vActivity < "4/1/2004" Then
'I want to use this ONE entry and stop checking
Else
'Do nothing and keep checking
End If
Else
'Don't do anything
End If
objRS.MoveNext
Loop
End If
I do I stop the checking this identifier and go on to the next one? The identifier is being pulled and used as a variable right before this, and there are literally hundreds of them.