FindRecord

  • Thread starter Thread starter Werx
  • Start date Start date
W

Werx

Hello

Say I have a form which Contains an autonumber used as the constant
RecordID, (when I delete records it rearranges the Record numbers in the Nav
Bar). And on this form i want a button that will recall a requested record
and all its values in the current form (which was initially used to create
the record) by finding a user entered RecordID. By user entered I mean when
I press the find button the form askes me to enter a RecordID.

How would I go about this?

Daniel
 
Say the name of the autonumber field in the table, is RecordID.

Put this code behind a command button.

(untested)

dim s as string, lngID as long
s = inputbox ("Enter record ID")
if strptr (s) = 0 then exit sub
lngID = val (s)
with me.recordsetclone
.findfirst "[RecordID]=" & lngID
if .nomatch then
msgbox "No such record"
else
me.bookmark = .bookmark
endif
end with

Cut & paste that code, so you do not miss any tricky leading fullstops etc.

You'd need to tart it up a bit - for example, what if someone enters
"xyz"? - but that should get you started.

HTH,
TC
 
Back
Top