Conditional Combo Box

  • Thread starter Thread starter samwise
  • Start date Start date
S

samwise

Guest
I too have a question about combo boxes.
I am fairly new to Access, and am learning through the blood, sweat and tears approach.

My problem is that I have a table for educational courses, both internal and external. I have a field in the table that uses a lookup from a second table containing course locations. So far so good, this works great in my form and selecting from the drop down inputs the data correctly.

Now I have a third table that stores data of specific locations of internal courses. I would like to be able to use the same combo box for both tables in the form. I have thought that I would add a check box for "Internal" course. I would like this to process a rule so that when "true" the combo box would draw data from table two, and when "false" would draw from table three.

I am completely stumped, and would much appreciate any help you could offer.
 
ComboBox

This should do it for you…

On the click event of the checkbox, select [Event Procedure] then , in code enter something like this:

Private Sub CheckBox_Click()
Dim strSQL As String
Dim strSQL2 As String

strSQL = "SELECT [NameOfField or Fields (separated with commas]FROM [NameOfTable 1]"
strSQL2 = "SELECT [NameOfField or Fields (separated with commas]FROM [NameOfTable 2]"

If Me.CheckBox = 1 Then
Me.ComboBox.RowSource = strSQL
ElseIf Me.CheckBox = 0 Then
Me.ComboBox.RowSource = strSQL2
End If
End Sub
 
You will find the whole process easier if you store all the courses in a single table with a field that identifies them as internal or external.
 

Users who are viewing this thread

Back
Top Bottom