I apologize for the above, this project is in 2007 not 2002
Hi, I have the following code I'm using to merge 2 current fields in a new table, along with other data.
It works as it should when there are multiple records in the one field, however, when there is only one record, it skips it. I cannot figure out what's wrong, any assistance would be great. I did not write this code myself, I had help.
Code:
Private Function usethis()
Dim rstmain As Recordset
Dim rsttbl As Recordset
Dim strfld As String
Dim strcasenbr As String
Set rstmain = CurrentDb.OpenRecordset("ICAC Report")
Set rsttbl = CurrentDb.OpenRecordset("copy of ICAC Export")
rstmain.MoveLast
rstmain.MoveFirst
strfld = ""
strcasenbr = rstmain![Case Number]
Do Until rstmain.EOF
Do While strcasenbr = rstmain![Case Number]
strfld = strfld & rstmain![Type] & vbCrLf
rstmain.MoveNext
If rstmain.EOF Then
rstmain.MovePrevious
GoTo skip
End If
Loop
skip:
rstmain.MovePrevious
rsttbl.AddNew
rsttbl!IntakeDate = rstmain![Intake Date]
rsttbl!DateRecent = rstmain![Date of Recent Activity]
rsttbl!TypeReceived = rstmain![Type Received]
rsttbl!NameandItems = rstmain![Subject] & vbcrrlf & strfld
rsttbl!CaseType = rstmain![Secondary Case Type]
rsttbl!CaseNumber = rstmain![Case Number]
rsttbl!Comments = rstmain![Comments]
rsttbl.Update
rstmain.MoveNext
rstmain.MoveNext
If rstmain.EOF Then GoTo iamdone
strcasenbr = rstmain![Case Number]
strfld = ""
Loop
iamdone:
End Function