Carmen
Registered User.
- Local time
- Today, 15:51
- Joined
- Nov 30, 2001
- Messages
- 58
Hi All,
I am racking my brain trying to figure out this loop...
Set rst = CurrentDb.OpenRecordset("ModuleStartDates", dbOpenDynaset)
mysearch = "[SSN]='" & Me.SSN & "'"
Do
rst.FindFirst mysearch
ModID = DLookup("[ModNbr]", "ModuleStartDates", mysearch)
For i = 1 To Len(ModID)
strChar = Mid$(ModID, i, 1)
Select Case strChar
Case "0"
'do nothing
Case Else
ID1 = ID1 & strChar
End Select
Next i
ID2 = ID1
If StrComp(ID2, onechar1, vbTextCompare) = 0 Or _
StrComp(ID2, onechar2, vbTextCompare) = 0 Then
answer2 = MsgBox("This teacher has already taken this Module.", vbOKOnly)
If answer2 = vbOK Then Exit Sub
End If
ID1 = ""
ID2 = ""
rst.MoveNext
Loop Until rst.NoMatch = True
This works great the first time through, but it is not looping through the records so ModID never changes. What I'm trying to do is loop through a person's class history to see if they are enrolling for a Module they have already taken. I have tried putting rst.FindFirst mysearch & the Dlookup outside the loop and that doesn't help. Can anyone please see what I'm doing wrong??? Thanks in advance!!!
Carmen
I am racking my brain trying to figure out this loop...
Set rst = CurrentDb.OpenRecordset("ModuleStartDates", dbOpenDynaset)
mysearch = "[SSN]='" & Me.SSN & "'"
Do
rst.FindFirst mysearch
ModID = DLookup("[ModNbr]", "ModuleStartDates", mysearch)
For i = 1 To Len(ModID)
strChar = Mid$(ModID, i, 1)
Select Case strChar
Case "0"
'do nothing
Case Else
ID1 = ID1 & strChar
End Select
Next i
ID2 = ID1
If StrComp(ID2, onechar1, vbTextCompare) = 0 Or _
StrComp(ID2, onechar2, vbTextCompare) = 0 Then
answer2 = MsgBox("This teacher has already taken this Module.", vbOKOnly)
If answer2 = vbOK Then Exit Sub
End If
ID1 = ""
ID2 = ""
rst.MoveNext
Loop Until rst.NoMatch = True
This works great the first time through, but it is not looping through the records so ModID never changes. What I'm trying to do is loop through a person's class history to see if they are enrolling for a Module they have already taken. I have tried putting rst.FindFirst mysearch & the Dlookup outside the loop and that doesn't help. Can anyone please see what I'm doing wrong??? Thanks in advance!!!
Carmen