R
RichKorea
I'm using an unbound combo box as the entry point for calling up service
records by the service tag number. The Row Source for the combo box is a
query that gets all of the existing tag numbers. The user can then start
typing in the tag number, and if it already existing, the combo box will go
to the right value, and then when the user hits enter or tab, the After
Update event runs a FindFirst to find the record. Setting Me.Bookmark loads
up the existing tag information and the user can update the tag.
For the times when the user is entering a number for the first time, I want
to use the NoMatch results to create a new record, store the tag number in
the tag field, and then the user can start entering data. I tried using
DoCmd.GoToRecord , , acNewRec, but I get an error message: Run-time error
'2499' You can't use the GoToRecord action or method on an object in Design
view.
The form is Open, not in Design View.
The code I'm using for the event is:
Private Sub SRNumber_Select_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[SRNumber] = '" & Me![SRNumber_Select] & "'"
If rs.NoMatch Then
DoCmd.GoToRecord , , acNewRec
Else
If Not rs.EOF Then
Me.Bookmark = rs.Bookmark
End If
End If
End Sub
Thanks, Rich
records by the service tag number. The Row Source for the combo box is a
query that gets all of the existing tag numbers. The user can then start
typing in the tag number, and if it already existing, the combo box will go
to the right value, and then when the user hits enter or tab, the After
Update event runs a FindFirst to find the record. Setting Me.Bookmark loads
up the existing tag information and the user can update the tag.
For the times when the user is entering a number for the first time, I want
to use the NoMatch results to create a new record, store the tag number in
the tag field, and then the user can start entering data. I tried using
DoCmd.GoToRecord , , acNewRec, but I get an error message: Run-time error
'2499' You can't use the GoToRecord action or method on an object in Design
view.
The form is Open, not in Design View.
The code I'm using for the event is:
Private Sub SRNumber_Select_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[SRNumber] = '" & Me![SRNumber_Select] & "'"
If rs.NoMatch Then
DoCmd.GoToRecord , , acNewRec
Else
If Not rs.EOF Then
Me.Bookmark = rs.Bookmark
End If
End If
End Sub
Thanks, Rich