F
Freeflyer
Hi,
I am trying to use VBA to update a field in a table - so far unsuccessfully.
My table has two fields, ContactName and ContactID.
My form only displays ContactName and this can be changed using a ComboBox
which is populated with a list of names (shown) and ID numbers (hidden).
Using the AfterUpdate event, I want to update the ContactID field for the
current record with the ID number for the Contact that was just selected.
So far I've got:
Private Sub cmbContactName_AfterUpdate()
Dim strSQL As String
strSQL = "UPDATE tblQuoteHeader " & _
"SET tblQuoteHeader.ContactID = '" & Me.cmbContactName.Column(1)
& "' " & _
"WHERE tblQuoteHeader.QuoteNumber = '" & Me.QuoteNumber & "';"
DoCmd.RunSQL (strSQL)
End Sub
Now this seems to work in itslef. However, it fails to update the record as
the form has Record Locking set to 'Edited Record'. Is there anyway round
this?
Regards
Michael
I am trying to use VBA to update a field in a table - so far unsuccessfully.
My table has two fields, ContactName and ContactID.
My form only displays ContactName and this can be changed using a ComboBox
which is populated with a list of names (shown) and ID numbers (hidden).
Using the AfterUpdate event, I want to update the ContactID field for the
current record with the ID number for the Contact that was just selected.
So far I've got:
Private Sub cmbContactName_AfterUpdate()
Dim strSQL As String
strSQL = "UPDATE tblQuoteHeader " & _
"SET tblQuoteHeader.ContactID = '" & Me.cmbContactName.Column(1)
& "' " & _
"WHERE tblQuoteHeader.QuoteNumber = '" & Me.QuoteNumber & "';"
DoCmd.RunSQL (strSQL)
End Sub
Now this seems to work in itslef. However, it fails to update the record as
the form has Record Locking set to 'Edited Record'. Is there anyway round
this?
Regards
Michael