So I'm trying to make a spot on my form that when a person selects a number from a drop down list, the number is then brought down to another part of the form and the number's description is displayed next to it. Any ideas?
So I'm trying to make a spot on my form that when a person selects a number from a drop down list, the number is then brought down to another part of the form and the number's description is displayed next to it. Any ideas?
take a look at this small one-liner for an example of how you might do it...
I should just be able to copy the code correct? and change the names of the tables and such?
So I tried copying and just putting the names of my tables and stuff to fit where needed, but it didn't work. How can I compress the file to share so people can tell me how much I've screwed up?
Last edited by dfelock; 12-17-2010 at 07:19 PM. Reason: New question
Trying to see if this attachment works...
This is what I currently have with the line of code you provided me Adam, with my stuff thrown in, but something isn't working....
hey bud,
your source of the dropdown is:and the code is right.Code:SELECT [Offenses].[ID], Offenses.[Offense] FROM Offenses;
the reason it doesn't work is because the code is reading the first column. you have two, because the source queries two fields. that trips everyone up the first time, I'm sure.
you can fix it two ways. change the source to:OR change the code to:Code:SELECT Offenses.[Offense] FROM Offenses;Code:Me.Text1 = Application.DLookup("OffenseDesc", "Offenses", "[Offense] = '" & Me.Combo13.Column(1, 0) & "'")
Okay, so I used the second code and it works, to a point. It only enters the first OffenseDesc each time no matter what Offense I pick.hey bud,
your source of the dropdown is:and the code is right.Code:SELECT [Offenses].[ID], Offenses.[Offense] FROM Offenses;
the reason it doesn't work is because the code is reading the first column. you have two, because the source queries two fields. that trips everyone up the first time, I'm sure.
you can fix it two ways. change the source to:OR change the code to:Code:SELECT Offenses.[Offense] FROM Offenses;Code:Me.Text1 = Application.DLookup("OffenseDesc", "Offenses", "[Offense] = '" & Me.Combo13.Column(1, 0) & "'")
Last edited by dfelock; 12-17-2010 at 10:28 PM. Reason: new issue
I'm sorry sir. Friday night I guess. this:was untested by me. My mistake. You need to reduce the query to one field. if you drop the id field completely, your initial code will be fine.Code:Me.Text1 = Application.DLookup("OffenseDesc", "Offenses", "[Offense] = '" & Me.Combo13.Column(1, 0) & "'")
My apologies once again.
By using the optional row argument of the column property of the combo box (the 0 >> Me.Combo13.Column(1, 0)), you are telling the result to always come from the first row (zero based).Okay, so I used the second code and it works, to a point. It only enters the first OffenseDesc each time no matter what Offense I pick.
You should use:
The default value is the bound column, which is column 0 (the first column).Code:Me.Combo13 or Me.Combo13.Column(0)
If you set the row source of the combo box to
then the control source for text box "Text1" would beCode:SELECT [Offenses].[ID], Offenses.[Offense] FROM Offenses;
first column (column zero) concatenated to the second column (column one)Code:Me.Text1 = Me.Combo13 & ", " & Me.Combo13.Column(1) or Me.Text1 = Me.Combo13.Column(0) & ", " & Me.Combo13.Column(1)