Question Three Comboboxes

arka74

New member
Local time
Today, 23:04
Joined
Jul 17, 2012
Messages
5
I am in the process of creating a register database.

:confused:Have three comboboxes
1) Products Category
2) Products
3) Packing

1. Select the category from the first combobox,
If the category is not available update the category table by enterting the category in the combobox

2. Based on the selection of the category combobox the products will be displayed in the products combobox.
Again if the product is not available update the products table

3. Based on the products combobox the packing will be displayed in the third combobox.

I was able to get the data in the second combobox based on the selection in the first combobox. But not going to the third one. Also to add a new item if not available.

Please guide me through.
 
Re: Three Comboboxes Synchronized

You need to look at Cascading Combo Box and also the Not In List Event behind the Combo Box.

Perhaps look at YouTube to get the idea, Link below:

http://www.youtube.com/watch?v=Im7P7jGivbQ

Code for the not in list event shown below:

Not In List Event

Private Sub id_NotInList(NewData As String, Response As Integer)
'Form Event Not In List
'Add item to Table
'Use of If Statement
'Recordset Add New and Update
'Remember to set Limit to List to Yes event to form
'Uses a Combo Box
Dim lngresp As Long
Dim db As Database
Dim rcd As Recordset
lngresp = MsgBox("Do you Want to Add this Item?", vbYesNo + vbExclamation, "Add to List")
If lngresp = vbYes Then
Set db = CurrentDb

Set rcd = db.OpenRecordset("tblHotel")
rcd.AddNew
'rcd![hotel].Value = Me.Text
rcd.Update
Response = acDataErrAdded
rcd.Close
Else
rsponse = acDataErrDisplay
End If

End Sub
 
Trevor's basic method above should work to add new items to the list, but don't forget to add another line of code that will requery the combo box after the new item has been added.
One useful thing I might add when users are having to make multiple selections or choices, when the form opens or the process starts, make only the first combo box visible and only when a valid selection has been made, make the second combo visible and so on. Just makes validation easier.
David
 

Users who are viewing this thread

Back
Top Bottom