Hi All,
Having a little problem with my combo box setup.
I have 3 combo boxes, 1st is division, 2nd is branch, 3rd is department. They all refer to a table which has 4 fields... they are the 3 I just mentioned and a 4th which is the department code.
The 3rd combo box contains the last to fields in its query with the dept code being bound to a field in another table (the field also appears on the form)
The problem is that from the 2nd combo box onwards the records that it shows arn't using the 'group by' feature that I selected when I created the query and when you select the department in the final combo box it does not enter the code into the field its supposed to.
But say you goto the last combo box first its obvious that the group by is working then and it puts the code into the field correctly, when you use the 2nd combo box first also the group by feature is working but if you then goto the 3rd one it has the same problem that I mentioned before.
Below is my code:
Option Compare Database
Private Sub cbobranch_Click()
If IsNull(Me![cbobranch]) Then
Me![cbodept].Visible = False
Me![lbldept].Visible = False
Exit Sub
Else
Me![cbodept].RowSource = "SELECT [tblDepartment].[Department] " _
& "FROM tblDepartment " _
& IIf(IsNull(Me![cbobranch]), "", "WHERE branch = '" & Me![cbobranch] & "'") _
& "ORDER BY [tblDepartment].[Department];"
Me![cbodept].Requery
Me![cbodept].Visible = True
Me![lbldept].Visible = True
End If
End Sub
Private Sub cbodiv_Click()
If IsNull(Me![cbodiv]) Then
Me![cbobranch].Visible = False
Me![lblbranch].Visible = False
Exit Sub
Else
Me![cbobranch].RowSource = "SELECT [tblDepartment].[Branch] " _
& "FROM tblDepartment " _
& IIf(IsNull(Me![cbodiv]), "", "WHERE Division = '" & Me![cbodiv] & "'") _
& "ORDER BY [tblDepartment].[Branch]"
Me![cbobranch].Requery
Me![cbobranch].Visible = True
Me![lblbranch].Visible = True
End If
End Sub
Private Sub Form_Load()
Me![cbodiv] = Null
Me![cbobranch] = Null
Me![cbodept] = Null
End Sub
---------------------------------------
Can anyone see what i'm doing wrong cause i've been messing with this for hours and can't get it to work.
Cheers,
Ryan
Having a little problem with my combo box setup.
I have 3 combo boxes, 1st is division, 2nd is branch, 3rd is department. They all refer to a table which has 4 fields... they are the 3 I just mentioned and a 4th which is the department code.
The 3rd combo box contains the last to fields in its query with the dept code being bound to a field in another table (the field also appears on the form)
The problem is that from the 2nd combo box onwards the records that it shows arn't using the 'group by' feature that I selected when I created the query and when you select the department in the final combo box it does not enter the code into the field its supposed to.
But say you goto the last combo box first its obvious that the group by is working then and it puts the code into the field correctly, when you use the 2nd combo box first also the group by feature is working but if you then goto the 3rd one it has the same problem that I mentioned before.
Below is my code:
Option Compare Database
Private Sub cbobranch_Click()
If IsNull(Me![cbobranch]) Then
Me![cbodept].Visible = False
Me![lbldept].Visible = False
Exit Sub
Else
Me![cbodept].RowSource = "SELECT [tblDepartment].[Department] " _
& "FROM tblDepartment " _
& IIf(IsNull(Me![cbobranch]), "", "WHERE branch = '" & Me![cbobranch] & "'") _
& "ORDER BY [tblDepartment].[Department];"
Me![cbodept].Requery
Me![cbodept].Visible = True
Me![lbldept].Visible = True
End If
End Sub
Private Sub cbodiv_Click()
If IsNull(Me![cbodiv]) Then
Me![cbobranch].Visible = False
Me![lblbranch].Visible = False
Exit Sub
Else
Me![cbobranch].RowSource = "SELECT [tblDepartment].[Branch] " _
& "FROM tblDepartment " _
& IIf(IsNull(Me![cbodiv]), "", "WHERE Division = '" & Me![cbodiv] & "'") _
& "ORDER BY [tblDepartment].[Branch]"
Me![cbobranch].Requery
Me![cbobranch].Visible = True
Me![lblbranch].Visible = True
End If
End Sub
Private Sub Form_Load()
Me![cbodiv] = Null
Me![cbobranch] = Null
Me![cbodept] = Null
End Sub
---------------------------------------
Can anyone see what i'm doing wrong cause i've been messing with this for hours and can't get it to work.
Cheers,
Ryan