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

hkc94501

Member
Local time
Tomorrow, 02:50
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
Today, 10:50
Joined
Oct 29, 2018
Messages
21,358
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
Tomorrow, 02:50
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
Tomorrow, 01:50
Joined
May 7, 2009
Messages
19,169
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: 334

Gasman

Enthusiastic Amateur
Local time
Today, 17:50
Joined
Sep 21, 2011
Messages
14,045
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
Today, 10:50
Joined
Oct 29, 2018
Messages
21,358
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, 20:50
Joined
Oct 28, 2021
Messages
335
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

Member
Local time
Today, 19:50
Joined
Aug 4, 2021
Messages
41
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, 20:50
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