freightguy
Registered User.
- Local time
- Today, 03:40
- Joined
- Mar 1, 2016
- Messages
- 36
Hello everyone - I've been at this recordset issue all week and decided to come here and see if anyone can help point out what I'm doing wrong.
my goal: send an email with the data that was entered by user
what works so far: if I use ONE recordset it works perfectly
where it fails: the moment I add a second recordset (main form has two subforms) it crashes
This is the code I used to set things up: (I figured creating a second instance of recordset would work. I suspect this is where my problem is)
thanking you all in advance.
Ray
my goal: send an email with the data that was entered by user
what works so far: if I use ONE recordset it works perfectly
where it fails: the moment I add a second recordset (main form has two subforms) it crashes
Code:
Me.[frmExportShipmentDetails].Form.Recordset.MoveFirst
Do While Not Me.[frmExportShipmentDetails].Form.Recordset.EOF
strBody = strBody & "Line Items: " & Me.[frmExportShipmentDetails]![ordProductCode] & " | " & Me.[frmExportShipmentDetails]![ordProductDesc] & Chr(13)
Me.[frmExportShipmentDetails].Form.Recordset.MoveNext
Loop
Me.[subfrmPelicanDIMS].Form.Recordset.MoveFirst [COLOR="DarkOrange"]' THIS IS WHERE I GET ERROR CODE 3021 - BUT I KNOW THERE IS A RECORD[/COLOR]
Do While Not Me.[subfrmPelicanDIMS].Form.Recordset.EOF& Chr(13)
strBody = strBody & "Details Items: " & Me.[subfrmPelicanDIMS]![Desc] & " | " & Me.[subfrmPelicanDIMS]![Case Nbr] & Chr(13)
Me.[subfrmPelicanDIMS].Form.Recordset.MoveNext
Loop
This is the code I used to set things up: (I figured creating a second instance of recordset would work. I suspect this is where my problem is)
Code:
Dim db As DAO.Database
Dim rsDetail As DAO.Recordset
Dim strSQL As String
Dim db2 As DAO.Database
Dim rsDetail2 As DAO.Recordset
Dim strSQL2 As String
strSQL = "SELECT * FROM tblexportShipment WHERE expinvnbr = '" & Me!ProjectNumber & "'"
strSQL2 = "SELECT * FROM tblPelicanDIMS WHERE expid = " & Me!expID & ""
On Error GoTo ErrorHandler 'trap the errors
Set db = CurrentDb()
Set rsDetail = db.OpenRecordset(strSQL)
Set db2 = CurrentDb()
Set rsDetail2 = db.OpenRecordset(strSQL2)
thanking you all in advance.
Ray
Last edited: