By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,850 Members | 972 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,850 IT Pros & Developers. It's quick & easy.

Find record - Simple problem

P: n/a
Hello

I want to search my database for a vehicle registration number but
before i can search using the Find Record button i created i have to
click in the registration field so that it is that one that is being
searched. Is there any way to just click the button and by default it
searches the registration field?

Or... is there a way where I can get the user to type in the
registration number in a text field then click a command button which
will find that record. That will be the ideal solution but I do not
know enough VB to program the button. Can anyone help with that?

Thanks for your time,
Regards, Gareth

Jun 27 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
If you put a command button on your form, you can SetFocus to the
Registration field, and the call the Find dialog. The Event Procedure for
the Click of your button would be something like this:

Private Sub cmdFind_Click()
If Me.Dirty Then Me.Dirty = False
Me.[Registration].SetFocus
RunCommand acCmdFind
End Sub

An unbound text box at the top of your form makes a very nice interface for
jumping to a record. You can use the AfterUpdate event of the text box, so
you just press Enter and it finds it. The code for the Event Procedure to
use in the text box's AfterUpdate would be identical to this:
http://allenbrowne.com/ser-03.html
Although that article talks about a combo, it's the same code for the text
box.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<gj********@volcanomail.com> wrote in message
news:11*********************@j72g2000cwa.googlegro ups.com...

I want to search my database for a vehicle registration number but
before i can search using the Find Record button i created i have to
click in the registration field so that it is that one that is being
searched. Is there any way to just click the button and by default it
searches the registration field?

Or... is there a way where I can get the user to type in the
registration number in a text field then click a command button which
will find that record. That will be the ideal solution but I do not
know enough VB to program the button. Can anyone help with that?

Thanks for your time,
Regards, Gareth

Jun 27 '06 #2

P: n/a
You can use a DLookup function behind your button, and it won't even
look at the registration field on your form. do something like:

X = InputBox("VIN")

Then do a DLookup in your table with the VINs and search for that value
of X.
gj********@volcanomail.com wrote:
Hello

I want to search my database for a vehicle registration number but
before i can search using the Find Record button i created i have to
click in the registration field so that it is that one that is being
searched. Is there any way to just click the button and by default it
searches the registration field?

Or... is there a way where I can get the user to type in the
registration number in a text field then click a command button which
will find that record. That will be the ideal solution but I do not
know enough VB to program the button. Can anyone help with that?

Thanks for your time,
Regards, Gareth


Jun 27 '06 #3

P: n/a
Thanks Allen... got the text box find thing working great now. Is there
a way to use a button though or can it only be done by pressing enter?

Thanks again,
Gareth
Allen Browne wrote:
If you put a command button on your form, you can SetFocus to the
Registration field, and the call the Find dialog. The Event Procedure for
the Click of your button would be something like this:

Private Sub cmdFind_Click()
If Me.Dirty Then Me.Dirty = False
Me.[Registration].SetFocus
RunCommand acCmdFind
End Sub

An unbound text box at the top of your form makes a very nice interface for
jumping to a record. You can use the AfterUpdate event of the text box, so
you just press Enter and it finds it. The code for the Event Procedure to
use in the text box's AfterUpdate would be identical to this:
http://allenbrowne.com/ser-03.html
Although that article talks about a combo, it's the same code for the text
box.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<gj********@volcanomail.com> wrote in message
news:11*********************@j72g2000cwa.googlegro ups.com...

I want to search my database for a vehicle registration number but
before i can search using the Find Record button i created i have to
click in the registration field so that it is that one that is being
searched. Is there any way to just click the button and by default it
searches the registration field?

Or... is there a way where I can get the user to type in the
registration number in a text field then click a command button which
will find that record. That will be the ideal solution but I do not
know enough VB to program the button. Can anyone help with that?

Thanks for your time,
Regards, Gareth


Jun 27 '06 #4

P: n/a
Add a command button, and move the code into the event procedure for the
Click of the button.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<gj********@volcanomail.com> wrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
Thanks Allen... got the text box find thing working great now. Is there
a way to use a button though or can it only be done by pressing enter?

Thanks again,
Gareth
Allen Browne wrote:
If you put a command button on your form, you can SetFocus to the
Registration field, and the call the Find dialog. The Event Procedure for
the Click of your button would be something like this:

Private Sub cmdFind_Click()
If Me.Dirty Then Me.Dirty = False
Me.[Registration].SetFocus
RunCommand acCmdFind
End Sub

An unbound text box at the top of your form makes a very nice interface
for
jumping to a record. You can use the AfterUpdate event of the text box,
so
you just press Enter and it finds it. The code for the Event Procedure to
use in the text box's AfterUpdate would be identical to this:
http://allenbrowne.com/ser-03.html
Although that article talks about a combo, it's the same code for the
text
box.

<gj********@volcanomail.com> wrote in message
news:11*********************@j72g2000cwa.googlegro ups.com...
>
> I want to search my database for a vehicle registration number but
> before i can search using the Find Record button i created i have to
> click in the registration field so that it is that one that is being
> searched. Is there any way to just click the button and by default it
> searches the registration field?
>
> Or... is there a way where I can get the user to type in the
> registration number in a text field then click a command button which
> will find that record. That will be the ideal solution but I do not
> know enough VB to program the button. Can anyone help with that?
>
> Thanks for your time,
> Regards, Gareth

Jun 27 '06 #5

P: n/a
Thanks, but will the code not change so that it references the text box
in some way? That was the bit i was unsure off?

Thanks again,
Gareth
Allen Browne wrote:
Add a command button, and move the code into the event procedure for the
Click of the button.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<gj********@volcanomail.com> wrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
Thanks Allen... got the text box find thing working great now. Is there
a way to use a button though or can it only be done by pressing enter?

Thanks again,
Gareth
Allen Browne wrote:
If you put a command button on your form, you can SetFocus to the
Registration field, and the call the Find dialog. The Event Procedure for
the Click of your button would be something like this:

Private Sub cmdFind_Click()
If Me.Dirty Then Me.Dirty = False
Me.[Registration].SetFocus
RunCommand acCmdFind
End Sub

An unbound text box at the top of your form makes a very nice interface
for
jumping to a record. You can use the AfterUpdate event of the text box,
so
you just press Enter and it finds it. The code for the Event Procedure to
use in the text box's AfterUpdate would be identical to this:
http://allenbrowne.com/ser-03.html
Although that article talks about a combo, it's the same code for the
text
box.

<gj********@volcanomail.com> wrote in message
news:11*********************@j72g2000cwa.googlegro ups.com...
>
> I want to search my database for a vehicle registration number but
> before i can search using the Find Record button i created i have to
> click in the registration field so that it is that one that is being
> searched. Is there any way to just click the button and by default it
> searches the registration field?
>
> Or... is there a way where I can get the user to type in the
> registration number in a text field then click a command button which
> will find that record. That will be the ideal solution but I do not
> know enough VB to program the button. Can anyone help with that?
>
> Thanks for your time,
> Regards, Gareth


Jun 27 '06 #6

P: n/a
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in
news:44**********************@per-qv1-newsreader-01.iinet.net.au:
Add a command button, and move the code into the event procedure
for the Click of the button.


Better still, add the command button with no code behind it and
leave the textbox alone. If the user clicks the command button
(which does nothing), it causes the focus to leave the textbox, thus
forcing the AfterUpdate event to fire. You then also get the benefit
for the user who is smart enough to know to hit ENTER.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Jun 27 '06 #7

P: n/a
The code from the link would be the same.

David's suggestion would also work.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<gj********@volcanomail.com> wrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
Thanks, but will the code not change so that it references the text box
in some way? That was the bit i was unsure off?

Thanks again,
Gareth
Allen Browne wrote:
Add a command button, and move the code into the event procedure for the
Click of the button.

<gj********@volcanomail.com> wrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
> Thanks Allen... got the text box find thing working great now. Is there
> a way to use a button though or can it only be done by pressing enter?
>
> Thanks again,
> Gareth
>
>
> Allen Browne wrote:
>> If you put a command button on your form, you can SetFocus to the
>> Registration field, and the call the Find dialog. The Event Procedure
>> for
>> the Click of your button would be something like this:
>>
>> Private Sub cmdFind_Click()
>> If Me.Dirty Then Me.Dirty = False
>> Me.[Registration].SetFocus
>> RunCommand acCmdFind
>> End Sub
>>
>> An unbound text box at the top of your form makes a very nice
>> interface
>> for
>> jumping to a record. You can use the AfterUpdate event of the text
>> box,
>> so
>> you just press Enter and it finds it. The code for the Event Procedure
>> to
>> use in the text box's AfterUpdate would be identical to this:
>> http://allenbrowne.com/ser-03.html
>> Although that article talks about a combo, it's the same code for the
>> text
>> box.
>>
>> <gj********@volcanomail.com> wrote in message
>> news:11*********************@j72g2000cwa.googlegro ups.com...
>> >
>> > I want to search my database for a vehicle registration number but
>> > before i can search using the Find Record button i created i have to
>> > click in the registration field so that it is that one that is being
>> > searched. Is there any way to just click the button and by default
>> > it
>> > searches the registration field?
>> >
>> > Or... is there a way where I can get the user to type in the
>> > registration number in a text field then click a command button
>> > which
>> > will find that record. That will be the ideal solution but I do not
>> > know enough VB to program the button. Can anyone help with that?
>> >
>> > Thanks for your time,
>> > Regards, Gareth

Jun 28 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.