F
FARAZ QURESHI
I have 2 Tables:
Branch: <Fields>
1. ID
2. Country
3. Branch
Sales: <Fields>
1. ID
2. Branch (Linked & looked up from the Branch Table)
3. Sales
Now the form "Sales" has the objects:
1. ID
2. Country (Unbound ComboBox With Row Source Being "SELECT DISTINCT
Branch.Country FROM Branch")
3. Branch (Combo Box)
4. Sales
I want the Branch ComboBox on the form to be showing all the Branches if no
Country is selected, however filtered cascading ComboBox pertaining to the
Country Selected if there is any selected so.
Following is the code I have tried but it results to a blank list of
Branches unless I select a Country.
Option Compare Database
Option Explicit
Private Sub Branch_GotFocus()
If Country = NULL Then
Branch.RowSource = "SELECT [Branch].[ID], [Branch].[Branch] FROM Branch"
Else
Branch.RowSource = "SELECT [Branch].[ID], [Branch].[Branch] FROM Branch
WHERE [Branch].[Country] = Country.Value"
End If
End Sub
What could be the error?
Branch: <Fields>
1. ID
2. Country
3. Branch
Sales: <Fields>
1. ID
2. Branch (Linked & looked up from the Branch Table)
3. Sales
Now the form "Sales" has the objects:
1. ID
2. Country (Unbound ComboBox With Row Source Being "SELECT DISTINCT
Branch.Country FROM Branch")
3. Branch (Combo Box)
4. Sales
I want the Branch ComboBox on the form to be showing all the Branches if no
Country is selected, however filtered cascading ComboBox pertaining to the
Country Selected if there is any selected so.
Following is the code I have tried but it results to a blank list of
Branches unless I select a Country.
Option Compare Database
Option Explicit
Private Sub Branch_GotFocus()
If Country = NULL Then
Branch.RowSource = "SELECT [Branch].[ID], [Branch].[Branch] FROM Branch"
Else
Branch.RowSource = "SELECT [Branch].[ID], [Branch].[Branch] FROM Branch
WHERE [Branch].[Country] = Country.Value"
End If
End Sub
What could be the error?