Hi All,
When processing the following code, I receive the attached error:
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
Dim db As Database
Dim rstInput As Recordset
Dim rstOutPut As Recordset
Dim strMeterNo As String
Set db = CurrentDb
stDocName = "iqry_Delete_Meter_Hours_List"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Set rstInput = db.OpenRecordset("iqry_Meter_Hours_List")
Set rstOutPut = db.OpenRecordset("tbl_Meter_Hours_List")
strMeterNo = ""
'Read first record from Input
rstInput.MoveFirst
strMeterNo = rstInput![PARKING_METER_NUMBER]
Debug.Print strMeterNo
With rstOutPut
.AddNew
!parking_meter_no = rstInput![PARKING_METER_NUMBER]
!totalservicehours = rstInput![inservicehours]
.Update
.Bookmark = rstOutPut.LastModified
End With
GoTo Exit_Resume
rstInput.MoveNext
strMeterNo = rstInput![PARKING_METER_NUMBER]
Do While Not rstInput.EOF
rstOutPut.FindFirst "[Parking_Meter_No] = '" & strMeterNo & "'" ' Error on this line'
If rstOutPut.NoMatch Then
With rstOutPut
.AddNew
!parking_meter_no = rstInput![PARKING_METER_NUMBER]
!totalservice = rstInput![inservicehours]
.Update
.Bookmark = rstOutPut.LastModified
End With
GoTo Exit_Resume
Else
With rstOutPut
.Edit
!totalservice = !totalservice + rstInput![inservicehours]
.Update
.Bookmark = rstOutPut.LastModified
End With
End If
Exit_Resume:
rstInput.MoveNext
strMeterNo = rstInput![PARKING_METER_NUMBER]
Loop
Exit_Command1_Click:
rstInput.Close
rstOutPut.Close
intResponse = MsgBox("Processing Completed", vbOKOnly)
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub
Processing Error
-
- Lounger
- Posts: 47
- Joined: 09 Feb 2010, 11:30
- Location: OH USA
Processing Error
You do not have the required permissions to view the files attached to this post.
-
- Lounger
- Posts: 47
- Joined: 09 Feb 2010, 11:30
- Location: OH USA
Re: Processing Error
Addendum: Both fields are text-type
-
- Administrator
- Posts: 78394
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Processing Error
Change the line
Set rstOutPut = db.OpenRecordset("tbl_Meter_Hours_List")
to
Set rstOutPut = db.OpenRecordset("tbl_Meter_Hours_List", dbOpenDynaset)
Without the extra argument, you cannot jump arbitrarily through the recordset.
Set rstOutPut = db.OpenRecordset("tbl_Meter_Hours_List")
to
Set rstOutPut = db.OpenRecordset("tbl_Meter_Hours_List", dbOpenDynaset)
Without the extra argument, you cannot jump arbitrarily through the recordset.
Best wishes,
Hans
Hans
-
- Lounger
- Posts: 47
- Joined: 09 Feb 2010, 11:30
- Location: OH USA
Re: Processing Error
Thanks Hans. As usual that did the trick. Enjoy the weekend.