Populate Form Based on User Entered Data

stuckincement

New Member
Joined
May 5, 2014
Messages
26
Hi All,

I have a form that displays information out of a table. I added a free-form text field where I would like a user to be able to enter a numeric value that then would be searched in a specific field in the table and then populate the form with that specific record's information. Any ideas?

I have tried this numerous ways in regards to having a macro run but have had no luck. Any help would be greatly appreciated!
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
The macro idea is correct...the macro would run an update query.
The upd query would look like

"update table Set [myfield] = '" & forms!frmMyForm!txtBoxUpdVal & "'"
 
Upvote 0
Thanks for your help! I put the update query in but am still having problems. Here is what my SQL code is:

UPDATE tblCharges SET tblCharges.[Trip Number] = '" & [Forms]![frmLTL_Estimated]![Text18] & "';

Text18 is the text box that a user will type in the numeric value to then be matched to the Trip Number field. tblCharges then is the table I would like to have the matching trip number record to be pulled from and displayed on this form.
 
Upvote 0
In case this thread is useful to anyone else, I was able to find a solution after a lot of hours of trial an error. In the end, I created a combo box on my form tied to the field. I used the following code to take the user entered value and move to that corresponding record:

Code:
Me.RecordsetClone.FindFirst "[Trip Number]=" & Me![Combo146]Me.Bookmark = Me.RecordsetClone.Bookmark

The combo box values are input via a quick SQL statement in the row source data field property:

Code:
SELECT [tblCharges].[Trip Number] FROM tblCharges ORDER BY [Trip Number];

To avoid an error from the initial open of the form you also need to set the default value - in this case I used the first expression to pull the first record's information to that field.

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,215,007
Messages
6,122,670
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top