Combo box dependant on another combo box issue

G

Guest

I have been on multiple forums and found help on this issue, yet I still am
having difficulties.

My form named frmAssignStudentsToClass has a subform named
sfrmAssignStudentToClass. Inside my subform I have two combo boxes, one of
which named cboClass with the row source based on the following query:

SELECT Classes.ClassID, Classes.ClassName FROM Classes ORDER BY [ClassName];

The other combo box is named cboDay and its row source is based on this query:

SELECT Sessions.SessionID, Sessions.Day, Sessions.ClassID FROM Sessions
WHERE
(((Sessions.ClassID)=Forms!frmAssignStudentsToClass!sfrmAssignStudentsToClass.Form!cboClass)) ORDER BY Sessions.Day;

I think I am doing this correctly, but when I run my form, I
get an input box asking me to type in a value for
"Forms!frmAssignStudentsToClass!sfrmAssignStudentsToClass!cboClass".

All I want is to be able to select a class in cboClass and have cboDay
display only those days that the selected class is offered on.

Any suggestions would be great!

- ivalum21
 
G

Guest

Here's one way you can try. In the AfterUpdate eventhandler for cboClass,
put in a statement to dynamically set the RowSource for cboDay e.g.

cboDay.RowSource = "
SELECT Sessions.SessionID, Sessions.Day, Sessions.ClassID FROM Sessions
WHERE (((Sessions.ClassID)= " & cboClass & " ORDER BY Sessions.Day;"

Hope This Helps
Gerald Stanley MCSD
 
G

Guest

This worked great! I was having problems with it, but then I cleared out
what I already had in the row source for that combo box then ran the form,
and it works great.

Thank you very much Mr. Stanley,
ivalum21

Gerald Stanley said:
Here's one way you can try. In the AfterUpdate eventhandler for cboClass,
put in a statement to dynamically set the RowSource for cboDay e.g.

cboDay.RowSource = "
SELECT Sessions.SessionID, Sessions.Day, Sessions.ClassID FROM Sessions
WHERE (((Sessions.ClassID)= " & cboClass & " ORDER BY Sessions.Day;"

Hope This Helps
Gerald Stanley MCSD

ivalum21 said:
I have been on multiple forums and found help on this issue, yet I still am
having difficulties.

My form named frmAssignStudentsToClass has a subform named
sfrmAssignStudentToClass. Inside my subform I have two combo boxes, one of
which named cboClass with the row source based on the following query:

SELECT Classes.ClassID, Classes.ClassName FROM Classes ORDER BY [ClassName];

The other combo box is named cboDay and its row source is based on this query:

SELECT Sessions.SessionID, Sessions.Day, Sessions.ClassID FROM Sessions
WHERE
(((Sessions.ClassID)=Forms!frmAssignStudentsToClass!sfrmAssignStudentsToClass.Form!cboClass)) ORDER BY Sessions.Day;

I think I am doing this correctly, but when I run my form, I
get an input box asking me to type in a value for
"Forms!frmAssignStudentsToClass!sfrmAssignStudentsToClass!cboClass".

All I want is to be able to select a class in cboClass and have cboDay
display only those days that the selected class is offered on.

Any suggestions would be great!

- ivalum21
 
G

Guest

I spoke too soon...

When I go into my frmAssignStudentToClass, I pick a class and the cboDay
variable updates properly, only displaying the day the class is offered.
BUT, when I go to another student and come back to the first student, the
cboDay combo box is blank. And when I go to my Sessions table, it has
inserted a new record and where the day should be (ex. Monday, Tuesday,
etc.), it has a number.

When I do it initially on the form, it seems to work fine. But if I go back
to check on that student, the cboDay combo box has changed...

Gerald Stanley said:
Here's one way you can try. In the AfterUpdate eventhandler for cboClass,
put in a statement to dynamically set the RowSource for cboDay e.g.

cboDay.RowSource = "
SELECT Sessions.SessionID, Sessions.Day, Sessions.ClassID FROM Sessions
WHERE (((Sessions.ClassID)= " & cboClass & " ORDER BY Sessions.Day;"

Hope This Helps
Gerald Stanley MCSD

ivalum21 said:
I have been on multiple forums and found help on this issue, yet I still am
having difficulties.

My form named frmAssignStudentsToClass has a subform named
sfrmAssignStudentToClass. Inside my subform I have two combo boxes, one of
which named cboClass with the row source based on the following query:

SELECT Classes.ClassID, Classes.ClassName FROM Classes ORDER BY [ClassName];

The other combo box is named cboDay and its row source is based on this query:

SELECT Sessions.SessionID, Sessions.Day, Sessions.ClassID FROM Sessions
WHERE
(((Sessions.ClassID)=Forms!frmAssignStudentsToClass!sfrmAssignStudentsToClass.Form!cboClass)) ORDER BY Sessions.Day;

I think I am doing this correctly, but when I run my form, I
get an input box asking me to type in a value for
"Forms!frmAssignStudentsToClass!sfrmAssignStudentsToClass!cboClass".

All I want is to be able to select a class in cboClass and have cboDay
display only those days that the selected class is offered on.

Any suggestions would be great!

- ivalum21
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top