Hello, I am very new to VBA, so please excuse the incompetence.
I am using the on-click property of a form object to store a field value of the current record and then insert it into a new record on my table. The syntax I have typed is:
Private Sub Insert_Record_Before_Click()
Dim lngmRecno As Long
lngmRecno = Me.Recno
DoCmd.RunSQL "insert into tblMain_Table (Recno) Values (lngmRecno)"
End Sub
Recno is the name of the field in the form and also on the table.
When I run this, it asks me to input the value of lngmRecno - I have already specified it with the lngmRecno = Me.Recno. Where is my syntax error?
Also, in the VBA edittor, I am unable to run this stepwise using the F8 function. Is this because the procedure is called by the form?
Thank you,
Rudra
I am using the on-click property of a form object to store a field value of the current record and then insert it into a new record on my table. The syntax I have typed is:
Private Sub Insert_Record_Before_Click()
Dim lngmRecno As Long
lngmRecno = Me.Recno
DoCmd.RunSQL "insert into tblMain_Table (Recno) Values (lngmRecno)"
End Sub
Recno is the name of the field in the form and also on the table.
When I run this, it asks me to input the value of lngmRecno - I have already specified it with the lngmRecno = Me.Recno. Where is my syntax error?
Also, in the VBA edittor, I am unable to run this stepwise using the F8 function. Is this because the procedure is called by the form?
Thank you,
Rudra