Search in specific field

D

DrewBe

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...
 
F

fredg

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]
 
Top