Find and select a record

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

Guest

Hi Group,
I would like to write a macro that finds and highlights a record within a
form. The form I'm working on has a few subforms attached to it. It contains
multiple records for patient referrals. I want to build a button that when
you click it, it pulls up a text box where you can enter in the patient's
unique id referral number and it will go to that record in the form and
highlight it so you can start typing away in whatever information needs to be
edited. Is this possible?
Thanks in advance,
Missa
 
Missa,

You can use the FindRecord action in a macro for this.

Rather than a separate form popping up, you could put an unbound textbox
in the Header section of the existing form, specificaly for navigating
to another record. Let's say this textbox is called "PatientFind", and
assuming the unique id is called "ReferralNumber", then the macro would
be like this...

Action: GoToControl
Control Name: [ReferralNumber]
Action: FindRecord
Find What: =[PatientFind]
Action: SetValue
Item: [PatientFind]
Expression: Null
 
Steve,
Thank you kindly for the help. I understand the directions you are relaying,
but I'm having a hard time getting the macro to work. When I click in the
new textbox, it automatically jumps to the field in the first record. It does
not allow me to type in the referral number I'd like to look up. Any ideas on
what I might be doing wrong?

Thanks!
Missa

Steve Schapel said:
Missa,

You can use the FindRecord action in a macro for this.

Rather than a separate form popping up, you could put an unbound textbox
in the Header section of the existing form, specificaly for navigating
to another record. Let's say this textbox is called "PatientFind", and
assuming the unique id is called "ReferralNumber", then the macro would
be like this...

Action: GoToControl
Control Name: [ReferralNumber]
Action: FindRecord
Find What: =[PatientFind]
Action: SetValue
Item: [PatientFind]
Expression: Null

--
Steve Schapel, Microsoft Access MVP

Hi Group,
I would like to write a macro that finds and highlights a record within a
form. The form I'm working on has a few subforms attached to it. It contains
multiple records for patient referrals. I want to build a button that when
you click it, it pulls up a text box where you can enter in the patient's
unique id referral number and it will go to that record in the form and
highlight it so you can start typing away in whatever information needs to be
edited. Is this possible?
Thanks in advance,
Missa
 
Missa,

What event have you assigned the macro? You mentioned in your original
post that you wanted to use a command button, and I assumed this would
still apply, i.e. that you would use the On Click event property of the
button for the macro, after the referral number is entered into the
textbox. Another option would be to not have a button, and use the
After Update event of the textbox. But it sounds like you have it on
the Enter or Click event of the textbox or some such?
 
Steve,
I have it on the "On Click" event. I will try it on the "On Enter" event to
see if it works better.

Thanks!
Missa
 
Missa,

Sounds like you missed my meaning. A Command Button doesn't have an
Enter event. If you are talking about the Textbox, then the After
Update event would be applicable. The Click event ot the Enter event of
the texxtbox won't work, since both these events occur before the
referral number is entered.
 
Hi Steve,

I am talking about a textbox. I am a bit thick-headed when it comes to these
things. =0)
Would you be so kind as to walk me through how to rig up a text box using
the "After Update" event to search for a record.
Thank you, I appreciate your patient help.

Missa
 
Missa,

You obviously know how to make a macro. And you obviosly know how to
assign that macro to an Event. Well, instead of assigning it on the
Click event or the Enter event, just put it on the After Update event
property of the textbox instead.

Mind you, as I already intimated, I probably wouldn't do it like that
myself. I would have the textbox for the entry of the referral number,
plus a Command Button, and I would not have the macro associated at all
with the textbox, I would have it on the Click event of the Command
Button instead.
 
Back
Top