Hi folks,
I have an button function:
Which when clicked, triggers this code:
It works perfectly - It runs a query based on the value just entered in 'Bath SN', takes a value from the query result and populates the V1_SN field on the actvie form.
The query is based on a previous record that has the equal value of 'Bath SN'.
This is all fine, but on some occasions, there will not be a matching value in a previous record for 'Bath SN'. When this happens, I get the VBA error 3021 - No current record.
Is there a way to skip this particular error for this piece of code? I can't seem to stop the error from firing and opening VBA etc.
I have an button function:
Code:
Private Sub Command266_Click()
Me.V1_SN = fnGetV1SN()
Which when clicked, triggers this code:
Code:
Public Function fnGetV1SN()
With CurrentDb.QueryDefs("Qry_AutoPop")
.Parameters(0) = Me![Bath SN]
fnGetV1SN = .OpenRecordset()(4)
End With
End Function
It works perfectly - It runs a query based on the value just entered in 'Bath SN', takes a value from the query result and populates the V1_SN field on the actvie form.
The query is based on a previous record that has the equal value of 'Bath SN'.
This is all fine, but on some occasions, there will not be a matching value in a previous record for 'Bath SN'. When this happens, I get the VBA error 3021 - No current record.
Is there a way to skip this particular error for this piece of code? I can't seem to stop the error from firing and opening VBA etc.