combo box problem

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

I've read thru the last years worth of msgs, but am still having a problem with
my two combo boxes. I want the second to be tied to the first, only displaying
those divisions particular to the selected department.

Here are my tables (just a portion):

DeptID Description
------ -----------
11 City Council
13 Executive
15 Admin - General
26 Judicial
32 Admin - Police
33 Admin - Fire
35 Fire Dept.
38 Public Safety
42 Public Works

DeptID DivisionID Description
------ ---------- -----------
38 0 E-911 Communications
46 0 Fleet Maint - Garage
47 0 Public Utilities
32 0 Support Services
11 10 City Council
13 10 Mayor
15 10 Finance

I have two combo boxes:

cboDepartments

cbo Divisions

I have [Event] code in After Update for cboDepartments:

Private Sub cboDepartments_AfterUpdate()

Me.cboDivisions.RowSource = "SELECT * FROM" & _
" tblDivisions WHERE DeptID = " Me.cboDepartments &
" ORDER BY Description"
Me.cboDivisions = Me.cboDivisions.ItemData(0)

End Sub

But I can't get it to work. I keep getting a compile error.

At one time I tried something like Me.cboDivisions.Requery. That didn't work
either.

If anyone could shed some light on this, I surely would appreciate it.

Thanks in advance,

Tom
 
I believe your missing an ampersand after the WHERE clause:

Private Sub cboDepartments_AfterUpdate()

Me.cboDivisions.RowSource = "SELECT * FROM" & _
" tblDivisions WHERE DeptID = " & _
Me.cboDepartments & " ORDER BY Description"
Me.cboDivisions = Me.cboDivisions.ItemData(0)

End Sub

HTH
Kevin Sprinkel
-----Original Message-----
I've read thru the last years worth of msgs, but am still having a problem with
my two combo boxes. I want the second to be tied to the first, only displaying
those divisions particular to the selected department.

Here are my tables (just a portion):

DeptID Description
------ -----------
11 City Council
13 Executive
15 Admin - General
26 Judicial
32 Admin - Police
33 Admin - Fire
35 Fire Dept.
38 Public Safety
42 Public Works

DeptID DivisionID Description
------ ---------- -----------
38 0 E-911 Communications
46 0 Fleet Maint - Garage
47 0 Public Utilities
32 0 Support Services
11 10 City Council
13 10 Mayor
15 10 Finance

I have two combo boxes:

cboDepartments

cbo Divisions

I have [Event] code in After Update for cboDepartments:

Private Sub cboDepartments_AfterUpdate()

Me.cboDivisions.RowSource = "SELECT * FROM" & _
" tblDivisions WHERE DeptID = " Me.cboDepartments &
" ORDER BY Description"
Me.cboDivisions = Me.cboDivisions.ItemData(0)

End Sub

But I can't get it to work. I keep getting a compile error.

At one time I tried something like
Me.cboDivisions.Requery. That didn't work
 
Tom,

Did adding the ampersand after the WHERE clause not work,
as I posted last week?

Kevin Sprinkel
-----Original Message-----
I've read thru the last years worth of msgs, but am still having a problem with
my two combo boxes. I want the second to be tied to the first, only displaying
those divisions particular to the selected department.

Here are my tables (just a portion):

DeptID Description
------ -----------
11 City Council
13 Executive
15 Admin - General
26 Judicial
32 Admin - Police
33 Admin - Fire
35 Fire Dept.
38 Public Safety
42 Public Works

DeptID DivisionID Description
------ ---------- -----------
38 0 E-911 Communications
46 0 Fleet Maint - Garage
47 0 Public Utilities
32 0 Support Services
11 10 City Council
13 10 Mayor
15 10 Finance

I have two combo boxes:

cboDepartments

cbo Divisions

I have [Event] code in After Update for cboDepartments:

Private Sub cboDepartments_AfterUpdate()

Me.cboDivisions.RowSource = "SELECT * FROM" & _
" tblDivisions WHERE DeptID = " Me.cboDepartments &
" ORDER BY Description"
Me.cboDivisions = Me.cboDivisions.ItemData(0)

End Sub

But I can't get it to work. I keep getting a compile error.

At one time I tried something like
Me.cboDivisions.Requery. That didn't work
 
My apologies for the multiple post. (This is my third
since last week.) I'm fighting another problem at the
moment. Using my regular client (Forte Free Agent) I
can't see my own posts. I've only seen this one because
I happened to remember that I could get to the MS
newsgroups via MS using IE. I swear, it's ALWAYS
something...

I'll try it shortly, thanks.
-----Original Message-----
Tom,

Did adding the ampersand after the WHERE clause not work,
as I posted last week?

Kevin Sprinkel
-----Original Message-----
I've read thru the last years worth of msgs, but am
still
having a problem with
my two combo boxes. I want the second to be tied to
the
first, only displaying
those divisions particular to the selected department.

Here are my tables (just a portion):

DeptID Description
------ -----------
11 City Council
13 Executive
15 Admin - General
26 Judicial
32 Admin - Police
33 Admin - Fire
35 Fire Dept.
38 Public Safety
42 Public Works

DeptID DivisionID Description
------ ---------- -----------
38 0 E-911 Communications
46 0 Fleet Maint - Garage
47 0 Public Utilities
32 0 Support Services
11 10 City Council
13 10 Mayor
15 10 Finance

I have two combo boxes:

cboDepartments

cbo Divisions

I have [Event] code in After Update for cboDepartments:

Private Sub cboDepartments_AfterUpdate()

Me.cboDivisions.RowSource = "SELECT * FROM" & _
" tblDivisions WHERE DeptID = " Me.cboDepartments &
" ORDER BY Description"
Me.cboDivisions = Me.cboDivisions.ItemData(0)

End Sub

But I can't get it to work. I keep getting a compile error.

At one time I tried something like
Me.cboDivisions.Requery. That didn't work
either.

If anyone could shed some light on this, I surely would appreciate it.

Thanks in advance,

Tom

.
.
 
That got it, thanks! (Now back to my regular reader
problem...)
-----Original Message-----
Tom,

Did adding the ampersand after the WHERE clause not work,
as I posted last week?

Kevin Sprinkel
-----Original Message-----
I've read thru the last years worth of msgs, but am
still
having a problem with
my two combo boxes. I want the second to be tied to
the
first, only displaying
those divisions particular to the selected department.

Here are my tables (just a portion):

DeptID Description
------ -----------
11 City Council
13 Executive
15 Admin - General
26 Judicial
32 Admin - Police
33 Admin - Fire
35 Fire Dept.
38 Public Safety
42 Public Works

DeptID DivisionID Description
------ ---------- -----------
38 0 E-911 Communications
46 0 Fleet Maint - Garage
47 0 Public Utilities
32 0 Support Services
11 10 City Council
13 10 Mayor
15 10 Finance

I have two combo boxes:

cboDepartments

cbo Divisions

I have [Event] code in After Update for cboDepartments:

Private Sub cboDepartments_AfterUpdate()

Me.cboDivisions.RowSource = "SELECT * FROM" & _
" tblDivisions WHERE DeptID = " Me.cboDepartments &
" ORDER BY Description"
Me.cboDivisions = Me.cboDivisions.ItemData(0)

End Sub

But I can't get it to work. I keep getting a compile error.

At one time I tried something like
Me.cboDivisions.Requery. That didn't work
either.

If anyone could shed some light on this, I surely would appreciate it.

Thanks in advance,

Tom

.
.
 
Back
Top