Macro to use the value of a textbox in a search (1 Viewer)

hkc94501

Member
Local time
Today, 08:31
Joined
Aug 6, 2021
Messages
38
I have a database with a bunch of data entry forms that are used for entering and editing records.
What I want to do is use the form to also search for specific records.
Specifically, I have a text box bound to an ID value (not the primary key, just a unique string), call it tbxID.
What I want is a before update event procedure that will look up the record that matches tbxID.text.
This procedure should not modify the record that was current when the search was started.

I'm pretty sure that I can do this in VB but I wonder if there isn't a simpler way to do it with a macro.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:31
Joined
Oct 29, 2018
Messages
19,134
Hi. Try adding an unbound Combobox using the Wizard and select the third option. If it creates an embedded macro, you can check it out and modify it to do what you want.
 

hkc94501

Member
Local time
Today, 08:31
Joined
Aug 6, 2021
Messages
38
Hi. Try adding an unbound Combobox using the Wizard and select the third option. If it creates an embedded macro, you can check it out and modify it to do what you want.
I think you are missing my point. I have a form that does data input and editing. There is a bound textbox that shows the value of an ID field (not the primary key). What I want is to be able to type a new value into that box and have the form move to the record matching the new value. I do not want to change the value in the underlying record for the original record. This would be similar to typing into the search box of the form controls.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:31
Joined
May 7, 2009
Messages
16,775
you can add another Textbox (dummy) and move it just below your ID textbox.
when the ID textbox GotFocus, you switch the focus to this dummy textbox.
see this demo.
 

Attachments

  • gotoRecord.accdb
    556 KB · Views: 199

Gasman

Enthusiastic Amateur
Local time
Today, 00:31
Joined
Sep 21, 2011
Messages
10,838
I think you are missing my point. I have a form that does data input and editing. There is a bound textbox that shows the value of an ID field (not the primary key). What I want is to be able to type a new value into that box and have the form move to the record matching the new value. I do not want to change the value in the underlying record for the original record. This would be similar to typing into the search box of the form controls.
Well it cannot be bound then, can it??? :unsure:
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:31
Joined
Oct 29, 2018
Messages
19,134
I think you are missing my point. I have a form that does data input and editing. There is a bound textbox that shows the value of an ID field (not the primary key). What I want is to be able to type a new value into that box and have the form move to the record matching the new value. I do not want to change the value in the underlying record for the original record. This would be similar to typing into the search box of the form controls.
Sorry, I didn't miss your point, but I didn't answer it directly. Instead, I gave you a way to figure it out on your own. You could have at least given it a try.
 

Sarah.M

Member
Local time
Today, 02:31
Joined
Oct 28, 2021
Messages
303
I have a database with a bunch of data entry forms that are used for entering and editing records.
What I want to do is use the form to also search for specific records.
Specifically, I have a text box bound to an ID value (not the primary key, just a unique string), call it tbxID.
What I want is a before update event procedure that will look up the record that matches tbxID.text.
This procedure should not modify the record that was current when the search was started.

I'm pretty sure that I can do this in VB but I wonder if there isn't a simpler way to do it with a macro.
Hi, I hope this help!
1. Use @arnelgp Demo DB
2. Go to Form Data and convert the Table to Query then follow the pictures bellow:
1
1635885756428.png

2
1635885856033.png
 

nectorch

New member
Local time
Today, 01:31
Joined
Aug 4, 2021
Messages
28
I think the filter method is the way to go , just bind that txt box to some combo box . First create unbound combo box base it to your record which you want to be searching , then simply filter that combo box with your text box , then you can use vba for the final update.
 

kadrleyn

New member
Local time
Today, 02:31
Joined
Feb 12, 2021
Messages
1
Check out this template :

search-in-workbook-1.gif


Source : eksi30.com/search-entire-workbook-list-result-cells/
 

Users who are viewing this thread

Top Bottom