Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 07-12-2019, 04:20 AM   #1
machinetech
Newly Registered User
 
Join Date: Jun 2019
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
machinetech is on a distinguished road
How to make a text box to perform as a combo/list box

I want to have a text box that auto-populates with a value its pulling from a query. I could do this with a combo box and have the record source using the dlookup function. However I do not want the user to have to select this value from the combo box.

However I still need the value to be saved to the control source. Currently I have the control source of the text box filled with the dlookup function, and it is retrieving the correct value, I now just need a way to have this value saved to the field I need it to be saved to when I save the record.

machinetech is offline   Reply With Quote
Old 07-12-2019, 04:49 AM   #2
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 32,954
Thanks: 13
Thanked 4,052 Times in 3,988 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: How to make a text box to perform as a combo/list box

http://allenbrowne.com/casu-14.html
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 07-12-2019, 11:42 AM   #3
Micron
Newly Registered User
 
Join Date: Oct 2018
Location: Ontario, Canada
Posts: 797
Thanks: 10
Thanked 161 Times in 155 Posts
Micron will become famous soon enough Micron will become famous soon enough
Re: How to make a text box to perform as a combo/list box

Never mind - I focused too much on the post title.


Quote:
However I do not want the user to have to select this value from the combo box.
BTW, you can have the value in a combo row without the user even seeing it and get it from there - if you can make the value part of the row source.

__________________
Sometimes I just roll my eyes out loud...
Windows 10; Office 365 (Access 2016)
Micron is offline   Reply With Quote
Old 07-12-2019, 02:41 PM   #4
MajP
Newly Registered User
 
Join Date: May 2018
Location: USA baby
Posts: 1,676
Thanks: 27
Thanked 505 Times in 478 Posts
MajP will become famous soon enough MajP will become famous soon enough
Re: How to make a text box to perform as a combo/list box

Quote:
However I still need the value to be saved to the control source. Currently I have the control source of the text box filled with the dlookup function, and it is retrieving the correct value, I now just need a way to have this value saved to the field I need it to be saved to when I save the record
If I understand this correctly, then simply do this in the forms on current event instead of the controls recordsource. Bind the control to the correct recordsource. In the forms on current event something like

Code:
if isnull(me.someTextbox) then
  me.someTextbox = yourDlookupFormula
end if
MajP is online now   Reply With Quote
The Following User Says Thank You to MajP For This Useful Post:
machinetech (07-15-2019)
Old 07-15-2019, 03:47 AM   #5
machinetech
Newly Registered User
 
Join Date: Jun 2019
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
machinetech is on a distinguished road
Re: How to make a text box to perform as a combo/list box

Quote:
Originally Posted by MajP View Post
If I understand this correctly, then simply do this in the forms on current event instead of the controls recordsource. Bind the control to the correct recordsource. In the forms on current event something like

Code:
if isnull(me.someTextbox) then
  me.someTextbox = yourDlookupFormula
end if
This is essentially what I did.
In the "On Change" Event Procedure for the preceeding combo box, I put in a dlookup function that looked like this:

Code:
Private Sub Combo1_Change()
     Text1 = Dlookup("[Field]", "Query")
End Sub
So this controls the input into the textbox, while I can still have the control source to the field the form is tied to.

Essentially a text box with a control source, that acts like a combo/list box with a row source.
machinetech is offline   Reply With Quote
Old 07-15-2019, 04:54 AM   #6
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 32,954
Thanks: 13
Thanked 4,052 Times in 3,988 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: How to make a text box to perform as a combo/list box

I would use the after update event; the change event fires with every keystroke.

__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Using macro to make command buttons perform queries and reports elektro Macros 2 09-25-2016 11:03 PM
Make one combo list depend on another guinness Forms 1 09-26-2014 08:11 AM
Does anyone know a way to make this Dlookup perform faster? papic1972 Forms 4 10-19-2010 02:45 PM
Can selecting a combo box make a text box visible again patentinv Forms 1 09-30-2005 03:33 AM
Can I make a Combo Box always show the first value in the list homer2002 Forms 1 09-05-2002 08:29 AM




All times are GMT -8. The time now is 12:28 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World