A
Asif
Hello
I have a orders form which has a subform called Orders
Subform. I want to be able to copy the previous record
over to the current record if required.
I have created a button and with the help of Eric (Thank
You) I have the following code which is in the On Click
event.
Private Sub CopyData_Click()
Dim rsttemp As ADODB.Recordset
Dim rsttemp1 As ADODB.Recordset
Dim sqlTemp As String
Set rsttemp = Forms!Orders.RecordsetClone
rsttemp.Bookmark = Forms!Orders.Bookmark
rsttemp.MovePrevious
sqlTemp = "SELECT * FROM Orders WHERE InvoiceNumber = "
& rsttemp!InvoiceNumber & ";"
Set rsttemp1 = New ADODB.Recordset
rsttemp1.Open sqlTemp, CurrentProject.Connection,
adOpenStatic
If rsttemp1.RecordCount > 0 Then
rsttemp.MoveFirst
Me.CustomerID = rsttemp1!field1
Me.VanID = rsttemp1!field2
Me.EmployeeID = rsttemp1!field3
Me.RequiredDate = rsttemp1!field4
Me.Orders_Subform!ProductID = rsttemp1!field5
Me.Orders_Subform!UnitPrice = rsttemp1!field6
End If
rsttemp.Close
rsttemp1.Close
End Sub
Now when I click on the button on my form it comes up with
the following error:
Run-Time Error '2196':
Can't retrieve the value of this property.
The following line is highlighted:
rsttemp.Bookmark = Forms!Orders.Bookmark
The database is a adp in Office XP Professional.
Thanking you in advance.
Asif
I have a orders form which has a subform called Orders
Subform. I want to be able to copy the previous record
over to the current record if required.
I have created a button and with the help of Eric (Thank
You) I have the following code which is in the On Click
event.
Private Sub CopyData_Click()
Dim rsttemp As ADODB.Recordset
Dim rsttemp1 As ADODB.Recordset
Dim sqlTemp As String
Set rsttemp = Forms!Orders.RecordsetClone
rsttemp.Bookmark = Forms!Orders.Bookmark
rsttemp.MovePrevious
sqlTemp = "SELECT * FROM Orders WHERE InvoiceNumber = "
& rsttemp!InvoiceNumber & ";"
Set rsttemp1 = New ADODB.Recordset
rsttemp1.Open sqlTemp, CurrentProject.Connection,
adOpenStatic
If rsttemp1.RecordCount > 0 Then
rsttemp.MoveFirst
Me.CustomerID = rsttemp1!field1
Me.VanID = rsttemp1!field2
Me.EmployeeID = rsttemp1!field3
Me.RequiredDate = rsttemp1!field4
Me.Orders_Subform!ProductID = rsttemp1!field5
Me.Orders_Subform!UnitPrice = rsttemp1!field6
End If
rsttemp.Close
rsttemp1.Close
End Sub
Now when I click on the button on my form it comes up with
the following error:
Run-Time Error '2196':
Can't retrieve the value of this property.
The following line is highlighted:
rsttemp.Bookmark = Forms!Orders.Bookmark
The database is a adp in Office XP Professional.
Thanking you in advance.
Asif