Search in specific field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to refine my abilities to search within the records with a
command button in form view. I need it to only search in the PRIMARY KEY
field. not in the field which the cursor is in...
 
I would like to refine my abilities to search within the records with a
command button in form view. I need it to only search in the PRIMARY KEY
field. not in the field which the cursor is in...

How does Access KNOW which PK value to go to?

Using an InputBox?

If the PK field is a Number datatype then, for example:

Me.RecordsetClone.FindFirst "[PKFieldName] =" & InputBox("What
value?")
Me.Bookmark = Me.RecordsetClone.Bookmark

If the PK field is a Text datatype, then:

Me.RecordsetClone.FindFirst "[ID] = '" & InputBox("What value?") & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark

You can adapt the above to a Control on a form to input the value to
be searched for...
Me.RecordsetClone.FindFirst "[PKFieldName] = " & Me![ControlName]
 

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

Back
Top