not a valid bookmark

  • Thread starter peljo via AccessMonster.com
  • Start date
P

peljo via AccessMonster.com

I have a function that finds a customer.When the customer does not exist, i
get the error not a valid bookmark.
Can you help me with my function ? Is there something wrong with it ? Can i
improve it and make it more stable ?

Public Function FindCustomer()
Dim f As Form
Set f = Forms!FCustomers
Dim strCustomerID As String
Dim strBookmark As String
strCustomerID = InputBox("Enter customer number ? ")
If strCustomerID = "" Then
Exit Function
End If
f.RecordsetClone.FindFirst "CustomerID = " & strCustomerID
If f.RecordsetClone.NoMatch Then
MsgBox "customer " & strCustomerID & " does not exist!!"
f.Bookmark = strBookmark
Else
f.Bookmark = f.RecordsetClone.Bookmark
End If

End Function
 
D

Dirk Goldgar

peljo via AccessMonster.com said:
I have a function that finds a customer.When the customer does not
exist, i get the error not a valid bookmark.
Can you help me with my function ? Is there something wrong with it ?
Can i improve it and make it more stable ?

Public Function FindCustomer()
Dim f As Form
Set f = Forms!FCustomers
Dim strCustomerID As String
Dim strBookmark As String
strCustomerID = InputBox("Enter customer number ? ")
If strCustomerID = "" Then
Exit Function
End If
f.RecordsetClone.FindFirst "CustomerID = " & strCustomerID
If f.RecordsetClone.NoMatch Then
MsgBox "customer " & strCustomerID & " does not exist!!"
f.Bookmark = strBookmark
Else
f.Bookmark = f.RecordsetClone.Bookmark
End If

End Function

This line is the source of the problem:
f.Bookmark = strBookmark

It serves no purpose anyway, and should just be deleted.

You'd do well to rewrite the last bit slightly, to access the
RecordsetClone property only once, like this:

With f.RecordsetClone
.FindFirst "CustomerID = " & strCustomerID
If .NoMatch Then
MsgBox "customer " & strCustomerID & " does not exist!!"
Else
f.Bookmark = .Bookmark
End If
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top