FindRecord

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
 
T

TC

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
 

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

Similar Threads

FindRecord 1
FindRecord 1
Separate Form 0
Chain of Custody Generation? 1
Dual purpose command button 5
Jump To Next Cost Code in Form 1
Command Button - Open report using current record 3
Log changes code 2

Top