Hi to all
I have two bounded forms: main form with a subform.
the subform has different records based on a value from the main form.
I want to update a field. I used an AfterUpdate event as follows:
Code:
Private Sub txtDateReturned_AfterUpdate()
Dim rstLibrary As Recordset
Set rstLibrary = CurrentDb.OpenRecordset(Name:="tblBooks", Type:=RecordsetTypeEnum.dbOpenDynaset)
On Error GoTo ProcError
' Update Status Book to show that is is returned
Dim strReturned As Long
strReturned = Me.cboBookTitle.Column(0)
Debug.Print "strReturned = "; strReturned
If Not IsNull(Me.txtDateReturned) Then
DoCmd.RunSQL "UPDATE tblbooks SET fkBookStatusId = 1 WHERE pkBookId=strReturned"
Else
' do nothing
End If
ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure AfterUpdate Event..."
Resume ExitProc
End Sub
Running the code gives a dialogue box titlesd: (Enter parameter value) and is asking me write the value of strReturned.
I need to type the value of the pkBookId of that record example: 20150 and it will work.
What is wrong in my code?
Khalil