Combo box delima

josephaldred

New member
Local time
Today, 09:30
Joined
Aug 1, 2009
Messages
8
Ok in making a combo box (using the wizard, I am a newbie) I chose the Last name, First name, ID, and Rate. In that order. I want the the combo box to display the Last name, and have a text box display the Rate. I figured out how to display the last name, but it dispalys the ID (which is the primary key for that table). With the bound column set to one, it displays Last name and ID in the text box. Changing it to 2 just displays Last name in both. 3 displays a blank in the combo box and Last name in the text box while changing it to 4 shows a blank box and Rate in the text box.

Does anyone have any suggestions? Like I said, I am new to database, I took a class about a year ago and haven't touched it since. Any help would be greatly appreciated.

Thanks,
Joseph
 
1-First of all...you have to determine the size (number of fields) and already did with the wizard.. so.. remember the first column takes the index 0 then 1 etc...ok
2-to fill a textbox from a combobox, you should use the .Column(Index) property.. example:
Code:
Private Sub Combo1_AfterUpdate()
Me.Text1= Me.Combo1.column(2)
End sub
above code fills text1 with data from the (3rd) column in the combo... so..
3-the bound property is to determine what is the default column that will give it's value to the combox when you use it in code,, from your example you have Last name, First name, Id, rate, so if you want your combo to store the ID set the bound column to 4.... coz here index start normally from 1, so,, to show a specific field when you choose a value from the combo write the actual index not the programming index
to show another value but keep the bound column as it is.. use the "Column widths" properity.. to hide all colums but show the last one, put 0;0;0;1 in this properity you will see only one column of data while it contains four and the bound column is the first for example,,,,,
to learn more about the combo... check all the properities it has and ue them in different settings to see hpw it goes,,,
HAMMAM
 
The bound column is the one whose value is the value property of the combobox.
The display is controlled by the combobox Column Widths property. Those not intended for display are set to zero width.

The textbox value is set by its Control Source.
You can refer to a column in the combobox like this:
comboboxname.Column(x)
Columns are numbered starting with (0).
 
Great. Thanks for the help.

This brings up another question. I want to take that rate multiply it by a number of hours that the user types into a Hours text box, and then save that final amount to the table. What I have so far is "=[Text21]*[Text27]" I just don't know what to add after that to send it to the table.

Thanks,
Joseph
 
Last edited:
What I have so far is "=[Text21]*[Text27]" I just don't know what to add after that to send it to the table.

Set the Control Source of the box to be the field in the Record Source of the form which is presumalby the table.

Use the After Update of the Hours text box to set the value.
textboxname = [Text21]*[Text27]

If you are already storing the hours and the rate in the table you would be adding a derived field. If it can be calculated on the fly in the future you should do that rather than storing both it and the values used to calculate it.

Also you would be well advised to use meaningful names for your controls rather than the defaults like Text21.
 

Users who are viewing this thread

Back
Top Bottom