UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Make More Details Appear When List Box Option Is Selected, Access 2016    
 
   
GreenHat101
post Jul 11 2019, 12:15 AM
Post#1



Posts: 1
Joined: 10-July 19



Hi guys,

I have a form with a combo box listing some options. Everytime something is selected from this list I want another textbox/label to display more details about this selection.

I used a change event but problem is the details part is also getting recorded down in my table which I don't want. The details are there just to help guide user to make a accurate selection from the list.
I don't need recorded in my table.

Any suggestion how I can make this happen? One idea I have is to put a VBA to delete the details feild after user moves to next record.

Appreciate any ideas and coding you can share with me on this.
Go to the top of the page
 
isladogs
post Jul 11 2019, 01:46 AM
Post#2


UtterAccess VIP
Posts: 1,451
Joined: 4-June 18
From: Somerset, UK


First of all is it a listbox (as in the title) or a combo (as in your post)?
Secondly, use the after update event rather than the change event.

In either case you can get an unbound text box to display the selection using e.g. Me.Textboxname= Me.Listboxname.
Doing that will not save the info to your table

However you said you wanted to show other unspecified details about that selection.
Are those detail in another table? If so, you could use a DLookup to obtain the values you want
Or possibly, that info could be a hidden column in your listbox.
If so you would use something like Me.Textboxname=Me.Listboxname.Column(1)

--------------------
Go to the top of the page
 
projecttoday
post Jul 11 2019, 04:37 AM
Post#3


UtterAccess VIP
Posts: 10,774
Joined: 10-February 04
From: South Charleston, WV


welcome2UA.gif

What is the purpose of the form? Why do you need a combo/list box?

Access won't update a table unless you tell it to, (either with bound fields or with code).

--------------------
Robert Crouser
Go to the top of the page
 
dale.fye
post Jul 11 2019, 05:36 AM
Post#4



Posts: 66
Joined: 28-March 18
From: Virginia


you might accomplish this two ways.

1. Modify the RowSource of the listbox (combo) to include the new field you want to display. Set the width of that column to 0 in the column width property of the control. Then, in the AfterUpdate event of the control, push the value of that field into your textbox (or a label).

CODE
Private Sub cboSomething_AfterUpdate

    me.txtDescription = me.cboSomething.columns(1)
'or, my preference
'   me.lblDescription.Caption = me.cboSomething.Columns(1)

End Sub
NOTE: The columns property of the combo/listbox is zero based, so you will need to figure out which column to use above.

2. The second method also involves the AfterUpdate event, but is designed for use when the text you want to display is greater than 255 characters (the limit for a column in a listbox of combo). In this case, you would use the value of the combo box to look up the description you want to display using the DLOOKUP domain function. Something like:

CODE
Private Sub cboSomething_AfterUpdate

    dim strCriteria as string

    strCriteria = "[SomeField] = " & me.cboSomething
    me.lblDescription.Caption = NZ(DLOOKUP("DescriptionFieldName", "yourTable", strCriteria), "")

End Sub


--------------------
Dale Fye
Microsoft Access MVP 2013-2016
Developing Solutions, LLC
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    16th July 2019 - 05:31 AM