Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combine data from mult. combo boxes to a single field. 1

Status
Not open for further replies.
May 10, 2001
10
I have five combo boxes (each box getting its' list of data from a table) on a form for a user to choose. I would like the data chosen in each of the boxes to be combined together to create a sort of ID number in another table to be used by other forms and queries. For example:

User fills out form called "LOG" with these values:

Combo1 01 [From table "SRVC_MONTH"]
Combo2 25 [From table "SRVC_DATE")
Combo3 03 [From table "SRVC_YEAR")
Combo4 WED [From table "SRVC_DAY")
Combo5 AM [From table "SRVC_TIME")

The chosen data is being stored in a table called "SERVICES".

The user clicks a command button that Saves the data and closes the form. At the time the user clicks "Save", the data should be put together in a string, stored in the "SERVICE_ID" column in the SERVICES table. The string would look like this:

"012503WEDAM"

Can someone help me with the OnClick code that would allow me to do this?

Thank you VERY much!

Aaron J. Mack
Blade Computer Services
 
Aaron, I'll try to answer your question but I would really recommend you changing your database design. Otherwise I think it will be very difficult for you in the future to parse the service ID and do anything with it. With that said...


Private Sub Form_AfterUpdate()
On Error GoTo Err_Form_AfterUpdate

DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO SERICES (SERVICE_ID) VALUES ('" & Combo1 & Combo2 & Combo3 & Combo4 & Combo5 & "');"
DoCmd.SetWarnings True

Exit_Form_AfterUpdate:
Exit Sub

Err_Form_AfterUpdate:
msgBox err.Description
Resume Exit_Form_AfterUpdate

End Sub
 
Thanks for the response. I'm taking your advice and doing something different....

Aaron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top