Hi,
In Access 2000, I need to take a table with 3 fields Data_ID, Dealer, User
and append another table with the same fields in a pipe “|” separated format.( this will be used in another application.)
Example:
Data_ID Dealer User
1234 ABC Dealer smitha
3423 DEF Dealer smitha
5545 GHI Dealer smitha
3323 JKL Dealer jonesd
3856 MNO Dealer jonesd
….
Output:
Data_ID Dealer User
1234|3423|5545 ABC Dealer|DEF Dealer||GHI Dealer smitha
3323|3856 JKL Dealer|MNO Dealer jonesd
The following function works until the last record. It errors with no current record and the last record isn’t written.
I don’t know how to get it to stop at the end and write the record.
Function CreateDealerList()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rst As DAO.Recordset
Dim strUsername As String
Dim StrSql As String
Set db = CurrentDb
StrSql = “SELECT tblDealers.DATA_ID, tblDealers.User, tblDealers.Dealer ” & _
“FROM tblDealers WHERE (((tblDealers.Status) = ‘Active’))ORDER BY tblDealers.User, tblDealers.Dealer;”
DoCmd.SetWarnings False
DoCmd.RunSQL “Delete tblDealerList.* From tblDealerList;”
DoCmd.SetWarnings True
Set rs = db.OpenRecordset(StrSql)
Set rst = db.OpenRecordset(“tblDealerList”)
Do While Not rs.EOF
strUsername = rs!User
rst.AddNew
rst!User = rs!User
Do Until strUsername rs!User
rst!Dealer = rst!Dealer & rs!Dealer & “|”
rst!Data_ID = rst!Data_ID & rs!Data_ID & “|”
rs.MoveNext
Loop
rst.Update
rs.MoveNext
Loop
End Function
Thanks for any help,
Scott