cconcat combo box values

vijay

Registered User.
Local time
Today, 16:38
Joined
Apr 28, 2003
Messages
16
Hi All,
Please help with the underlying problem.
i have 2 combo boxes.
combo_box1 of them has values "january","april","july" and "october".
combo_box2 has values 2001,2002,2003.
after the user selects the values,i need to concat the values,and store it in an underlying table as "01-combo_box1.value-combo_box2.value".

Thanks
 
The simplest way is to create a select query with the table having field called something like "Result" to hold the concatenated values as the recordsource for the form.

Put the two combo boxes, and the Result field on the form. In the AfterUpdate events of both combo boxes, use this code:
Me.txtResult = Me.cbo1 & "-" & Me.cbo2
(where txtResult is the Result text field).

When the user moves to another record, the value in the field will be automatically saved to the table. Alternatively, you could use a command button called something like "Save record" that saves the record and moves to a new record.
 
I would not recommend storing these two fields as one concatenated field. You'll just have to separate them if you want to sort by this field for example. It is better practice to store them separately. Of course if you want to turn them into a real date/time data type by adding a day (the first is the best choice), that would be better practice. Then you can use any date functions on the field as well as sort properly by it.
 
Thanks a lot.
Now since thats taken care of,i have another doubt..

when i query,how can i display "jan","apr" etc in the same combo box ?my dates are stored as "01-jan-01" .
Thanks again
 
Base the combobox on a query and format the date however you want. Use the Format property in the control's property sheet.
 
Thanks...
when i format the combo box, it shows up as "01-jan-01".
But how can i get it to display ,for ex:"Jan" instead of the pre-determined formats?
 

Users who are viewing this thread

Back
Top Bottom