Cascading Combo Boxes (Multiple boxes)

A

Adam

Im new to Access, but heres what's going on:

I have a Spreadsheet with about 13 columns, each column a different
specification for offshore drilling rigs. So i have 13 different combo boxes.

I have set up a form with 13 combo boxes, each pertaining to a column in my
table. The first three combo boxes are Rig Name, Owner, and World Region. I
have it working thus far to where i can use the drop down menu of combo box
(CB) 1 and choose a Rig Name out of the drop down. I can then proceed to CB 2
and it takes CB 1 info and narrows down the list to the Owner of the Rig in
CB 1. I can proceed through all 13 CB as longas i go in order and it will
work fine.

What i need to do is have this set up to where i can go in a random order
through the 13 combo boxes. I have been doing all of this without using
visual basic, and would prefer to not have to learn that program, but i have
a feeling it would be easiest in the long run.

Thanks for the help.
 
M

Mark A. Sam

Adam,

You should be able to select from the combo boxes in any order. What is the
problem when you go out of order?

God Bless,

Mark A. Sam
 
A

Adam

Mark,
When i go out of order, the combo boxes contain nothing; the drop down menus
are blank. I've created the form by doing a query i believe in every combo
box (in the "Row Sourse" field of the properties box).
 
A

Adam

Yes, for the criteria of the combo box being used, it is linked to the column
in the table ( [retry MODU List]![OWNER] ). For the criteria of the combo box
which preceeds it, i have the value in the form ( [Forms]![works straight
thru5]![Rig Name] ).

In my thinking, i would have thought to create a query in each combo box
that has a criteria for all 13 fields. And have them all linked to the form
value, but this does not work when the form value is empty. If i can be more
clear, please tell me, i know this is or can be confusing to write/read about.
 
M

Mark A. Sam

Disregard my last question. I reread your post and see that you are
narrowing each combo list down.

I have never been able to figure out an expression that will allow all
values to be shown if there is nothing in the criteria field. I'm not sure
why it isn't allowed. The best way I could see to approach this is the
allow all the whole list to be displayed and reset the the rowsource of the
following combo whenever you select from any combo. It isn't difficult to
do, but difficult to explain to someone who doesn't program.
 
M

Mark A. Sam

I'll try to give you an example of how to do this:

Let say there are two combo's, [Cbo1] and [Cbo2] in [Table1]. The rowsource
on each should be set without criteria.

If you select a value for [Cbo1] you will need to reset the rowsource for
[Cbo2] in the AfterUpdate event. It would look something like this:

Private Sub cbo1_AfterUpdate()

If IsNull(Me.ActiveControl) Then
[Cbo2].RowSource = "SELECT Table1.Field2, Table1.Field1 " & _
"From Table1 " & _
"WHERE Table1.Field1= '" & [Forms]![Form1]![cbo1] & "';"
Else
[Cbo2].RowSource = "SELECT Table1.Field2, Table1.Field1 FROM Table1;"
End If

End Sub


Notice the Where Clause.

"WHERE Table1.Field1= '" & [Forms]![Form1]![cbo1] * "';"
It may be difficult to see, but there are single quotes on the inside of the
double quotes

Field1''" and & "'

This is becuase [Cbo1] is a text field and a text value needs to be
surrounded by quotes. If [Cbo1] was a number field the expression woul
like like this:

"WHERE Table1.Field1= " & [Forms]![Form1]![cbo1]

If it was a Date feld it would look like this:

"WHERE Table1.Field1= #" & [Forms]![Form1]![cbo1] & "#;"

So surround a text value with single quotes and a Date value with # signs.


Hope that helps you and God Bless,

Mark A. Sam
 
A

Adam

Not too sure if i am doing this correctly, but thats why i'm here.

Ive knocked down my 13 combo boxes i need to have down to 4, just to
simplify this until i figure it out, but my combo boxes are:
[Rig Name]
[Owner]
[Rig Heading]
[Mooring Type]

My table is named MODU

and here is what i put into the after update box from what you had posted
(with added nonsense, im sure, since im not into coding)

Private Sub Rig_Name_AfterUpdate()
If IsNull(Me.ActiveControl) Then
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[RIG HEADING].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[MOORING TYPE].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
"From MODU " & _
"WHERE MODU.RIG_NAME= '" & [Forms]![MODULIST]![RIG NAME] & "';"
Else
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"
[RIG HEADING].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"
[MOORING TYPE].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"

End If
End Sub
 
M

Mark A. Sam

No that's wrong. You are trying to assign the rowsource for all of the
combo boxes. It is like this, where you are only setting the Rowsource from
[Owner] if [Rig] gets a value.

Private Sub Rig_Name_AfterUpdate()
If IsNull(Me.ActiveControl) Then
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
"From MODU " & _
"WHERE MODU.RIG_NAME= '" & [Forms]![MODULIST]![RIG NAME] & "';"
Else
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"
End If
End Sub


If [Owner] gets a value, then set the Rowsource for [Rig Heading], etc.


Adam said:
Not too sure if i am doing this correctly, but thats why i'm here.

Ive knocked down my 13 combo boxes i need to have down to 4, just to
simplify this until i figure it out, but my combo boxes are:
[Rig Name]
[Owner]
[Rig Heading]
[Mooring Type]

My table is named MODU

and here is what i put into the after update box from what you had posted
(with added nonsense, im sure, since im not into coding)

Private Sub Rig_Name_AfterUpdate()
If IsNull(Me.ActiveControl) Then
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[RIG HEADING].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[MOORING TYPE].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
"From MODU " & _
"WHERE MODU.RIG_NAME= '" & [Forms]![MODULIST]![RIG NAME] & "';"
Else
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"
[RIG HEADING].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"
[MOORING TYPE].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"

End If
End Sub




Mark A. Sam said:
Disregard my last question. I reread your post and see that you are
narrowing each combo list down.

I have never been able to figure out an expression that will allow all
values to be shown if there is nothing in the criteria field. I'm not
sure
why it isn't allowed. The best way I could see to approach this is the
allow all the whole list to be displayed and reset the the rowsource of
the
following combo whenever you select from any combo. It isn't difficult
to
do, but difficult to explain to someone who doesn't program.
 
A

Adam

I think im having a problem understanding the logic behind this, sorry. But
the post you said i did wrong, why is it not necessary to assign the
rowsource under the "If IsNull" part like this:

Private Sub Rig_Name_AfterUpdate()
If IsNull(Me.ActiveControl) Then
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[RIG HEADING].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[MOORING TYPE].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _


The way i understand this is, it is saying that if the Rig Name box is
empty, then the [owner], [rig heading], and [mooring type] combo boxes get
their values from the table. And since i would like to go in a random order
through my boxes, i would have thought that its necessary to have all
rowsource values assigned there.

Does my logic make sense at all? Or how should the code be read to make
sense to me?

Also, i have not gotten my form to work yet sadly.



Mark A. Sam said:
No that's wrong. You are trying to assign the rowsource for all of the
combo boxes. It is like this, where you are only setting the Rowsource from
[Owner] if [Rig] gets a value.

Private Sub Rig_Name_AfterUpdate()
If IsNull(Me.ActiveControl) Then
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
"From MODU " & _
"WHERE MODU.RIG_NAME= '" & [Forms]![MODULIST]![RIG NAME] & "';"
Else
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"
End If
End Sub


If [Owner] gets a value, then set the Rowsource for [Rig Heading], etc.


Adam said:
Not too sure if i am doing this correctly, but thats why i'm here.

Ive knocked down my 13 combo boxes i need to have down to 4, just to
simplify this until i figure it out, but my combo boxes are:
[Rig Name]
[Owner]
[Rig Heading]
[Mooring Type]

My table is named MODU

and here is what i put into the after update box from what you had posted
(with added nonsense, im sure, since im not into coding)

Private Sub Rig_Name_AfterUpdate()
If IsNull(Me.ActiveControl) Then
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[RIG HEADING].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[MOORING TYPE].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
"From MODU " & _
"WHERE MODU.RIG_NAME= '" & [Forms]![MODULIST]![RIG NAME] & "';"
Else
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"
[RIG HEADING].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"
[MOORING TYPE].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"

End If
End Sub




Mark A. Sam said:
Disregard my last question. I reread your post and see that you are
narrowing each combo list down.

I have never been able to figure out an expression that will allow all
values to be shown if there is nothing in the criteria field. I'm not
sure
why it isn't allowed. The best way I could see to approach this is the
allow all the whole list to be displayed and reset the the rowsource of
the
following combo whenever you select from any combo. It isn't difficult
to
do, but difficult to explain to someone who doesn't program.




Do you have anything in the criteria of the queries?
 
A

Adam

That is what is needed of the form, i too think its redundant as Excel has
each column header as a combo-type box, where you can filter by using any of
the 13 column criteria, but i was asked to make an access form...

Yea the only way i saw doing it was making an endless amount of scenarios,
but i thought there might be a better way. thanks for the link, ill check it
out and see what i can manage to do.



Beetle284 via AccessMonster.com said:
I have seen some of your previous posts on this, so I think I know
what you are trying to do. I also think it's not going to work. As I
understand it, you want to be able to make selections in any number
of your combo boxes, in any random order you choose, and then have
the remaining combo boxes filtered based on those selections. So, each
time you make a selection in a combo, you will have loop through all of
the other 12 combo boxes and first determine if they have a value. If they
do, then you would need to build a new criteria string to be used by
whatever combo boxes remain that are null. This would result in you
having to code for literally hundreds of possible scenarios. It's possible
I suppose, but not exactly feasible (at least as far as I can see).

A better option would be to just build a string based upon whatever
selections are made, and then use that string as a filter. There is a good
example of this type of search form at this link;

http://allenbrowne.com/ser-62.html
I think im having a problem understanding the logic behind this, sorry. But
the post you said i did wrong, why is it not necessary to assign the
rowsource under the "If IsNull" part like this:

Private Sub Rig_Name_AfterUpdate()
If IsNull(Me.ActiveControl) Then
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[RIG HEADING].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[MOORING TYPE].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _

The way i understand this is, it is saying that if the Rig Name box is
empty, then the [owner], [rig heading], and [mooring type] combo boxes get
their values from the table. And since i would like to go in a random order
through my boxes, i would have thought that its necessary to have all
rowsource values assigned there.

Does my logic make sense at all? Or how should the code be read to make
sense to me?

Also, i have not gotten my form to work yet sadly.
No that's wrong. You are trying to assign the rowsource for all of the
combo boxes. It is like this, where you are only setting the Rowsource from
[quoted text clipped - 63 lines]
Do you have anything in the criteria of the queries?

--
________________________

Sean Bailey
s b a i l e y 2 8 4 AT e c e n t r a l DOT c o m

Message posted via AccessMonster.com
 
M

Mark A. Sam

Adam,

You now have 4 combo boxes. Let's call them C1,C2,C3 and C4 from left to
right. Iniailly, none should have any criteria so that all of the
selections display in each combo.

If you select a value for C1 then only C2's rowsource needs to be updated,
because only it will look at C1 for its filtering. C1 filters C2 and only
C2.

If you select a value for C2 then C3 and only C3's rowsource needs to be
updated. Of if you select a value for C3 and not C2, then only C4'
Rowsource needs to be changed.

For any selection, you only need to update the rowsource of the combo to the
right of the selected combo.

What you seem to be doing is updating the rowsource of multiple combos. I
hope that makes sense.

God Bless,

Mark


Adam said:
I think im having a problem understanding the logic behind this, sorry. But
the post you said i did wrong, why is it not necessary to assign the
rowsource under the "If IsNull" part like this:

Private Sub Rig_Name_AfterUpdate()
If IsNull(Me.ActiveControl) Then
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[RIG HEADING].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[MOORING TYPE].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _


The way i understand this is, it is saying that if the Rig Name box is
empty, then the [owner], [rig heading], and [mooring type] combo boxes get
their values from the table. And since i would like to go in a random
order
through my boxes, i would have thought that its necessary to have all
rowsource values assigned there.

Does my logic make sense at all? Or how should the code be read to make
sense to me?

Also, i have not gotten my form to work yet sadly.



Mark A. Sam said:
No that's wrong. You are trying to assign the rowsource for all of the
combo boxes. It is like this, where you are only setting the Rowsource
from
[Owner] if [Rig] gets a value.

Private Sub Rig_Name_AfterUpdate()
If IsNull(Me.ActiveControl) Then
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
"From MODU " & _
"WHERE MODU.RIG_NAME= '" & [Forms]![MODULIST]![RIG NAME] & "';"
Else
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"
End If
End Sub


If [Owner] gets a value, then set the Rowsource for [Rig Heading], etc.


Adam said:
Not too sure if i am doing this correctly, but thats why i'm here.

Ive knocked down my 13 combo boxes i need to have down to 4, just to
simplify this until i figure it out, but my combo boxes are:
[Rig Name]
[Owner]
[Rig Heading]
[Mooring Type]

My table is named MODU

and here is what i put into the after update box from what you had
posted
(with added nonsense, im sure, since im not into coding)

Private Sub Rig_Name_AfterUpdate()
If IsNull(Me.ActiveControl) Then
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[RIG HEADING].RowSource = "SELECT MODU.MOORING_TYPE,
MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[MOORING TYPE].RowSource = "SELECT MODU.MOORING_TYPE,
MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
"From MODU " & _
"WHERE MODU.RIG_NAME= '" & [Forms]![MODULIST]![RIG NAME] & "';"
Else
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"
[RIG HEADING].RowSource = "SELECT MODU.MOORING_TYPE,
MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"
[MOORING TYPE].RowSource = "SELECT MODU.MOORING_TYPE,
MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"

End If
End Sub




:

Disregard my last question. I reread your post and see that you are
narrowing each combo list down.

I have never been able to figure out an expression that will allow all
values to be shown if there is nothing in the criteria field. I'm not
sure
why it isn't allowed. The best way I could see to approach this is
the
allow all the whole list to be displayed and reset the the rowsource
of
the
following combo whenever you select from any combo. It isn't
difficult
to
do, but difficult to explain to someone who doesn't program.




Do you have anything in the criteria of the queries?
 
A

Adam

Mark,
Wouldn't that method still only allow me to go forwards through the combo
boxes? (1 to 2, 2 to 3; or start with 2 then to 3, 3 to 4, etc.) Through the
4 different posts i have throughout these forums, i've nearly given up on
what i need being possible (without writing endless amounts of codes for
going every which way through 13 combo boxes.)

I really appreciate all the feedback i have gotten though, none the less,
and ive learned visual basic isnt too scary to attempt.





Mark A. Sam said:
Adam,

You now have 4 combo boxes. Let's call them C1,C2,C3 and C4 from left to
right. Iniailly, none should have any criteria so that all of the
selections display in each combo.

If you select a value for C1 then only C2's rowsource needs to be updated,
because only it will look at C1 for its filtering. C1 filters C2 and only
C2.

If you select a value for C2 then C3 and only C3's rowsource needs to be
updated. Of if you select a value for C3 and not C2, then only C4'
Rowsource needs to be changed.

For any selection, you only need to update the rowsource of the combo to the
right of the selected combo.

What you seem to be doing is updating the rowsource of multiple combos. I
hope that makes sense.

God Bless,

Mark


Adam said:
I think im having a problem understanding the logic behind this, sorry. But
the post you said i did wrong, why is it not necessary to assign the
rowsource under the "If IsNull" part like this:

Private Sub Rig_Name_AfterUpdate()
If IsNull(Me.ActiveControl) Then
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[RIG HEADING].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[MOORING TYPE].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _


The way i understand this is, it is saying that if the Rig Name box is
empty, then the [owner], [rig heading], and [mooring type] combo boxes get
their values from the table. And since i would like to go in a random
order
through my boxes, i would have thought that its necessary to have all
rowsource values assigned there.

Does my logic make sense at all? Or how should the code be read to make
sense to me?

Also, i have not gotten my form to work yet sadly.



Mark A. Sam said:
No that's wrong. You are trying to assign the rowsource for all of the
combo boxes. It is like this, where you are only setting the Rowsource
from
[Owner] if [Rig] gets a value.

Private Sub Rig_Name_AfterUpdate()
If IsNull(Me.ActiveControl) Then
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
"From MODU " & _
"WHERE MODU.RIG_NAME= '" & [Forms]![MODULIST]![RIG NAME] & "';"
Else
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"
End If
End Sub


If [Owner] gets a value, then set the Rowsource for [Rig Heading], etc.


Not too sure if i am doing this correctly, but thats why i'm here.

Ive knocked down my 13 combo boxes i need to have down to 4, just to
simplify this until i figure it out, but my combo boxes are:
[Rig Name]
[Owner]
[Rig Heading]
[Mooring Type]

My table is named MODU

and here is what i put into the after update box from what you had
posted
(with added nonsense, im sure, since im not into coding)

Private Sub Rig_Name_AfterUpdate()
If IsNull(Me.ActiveControl) Then
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[RIG HEADING].RowSource = "SELECT MODU.MOORING_TYPE,
MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[MOORING TYPE].RowSource = "SELECT MODU.MOORING_TYPE,
MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
"From MODU " & _
"WHERE MODU.RIG_NAME= '" & [Forms]![MODULIST]![RIG NAME] & "';"
Else
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"
[RIG HEADING].RowSource = "SELECT MODU.MOORING_TYPE,
MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"
[MOORING TYPE].RowSource = "SELECT MODU.MOORING_TYPE,
MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"

End If
End Sub




:

Disregard my last question. I reread your post and see that you are
narrowing each combo list down.

I have never been able to figure out an expression that will allow all
values to be shown if there is nothing in the criteria field. I'm not
sure
why it isn't allowed. The best way I could see to approach this is
the
allow all the whole list to be displayed and reset the the rowsource
of
the
following combo whenever you select from any combo. It isn't
difficult
to
do, but difficult to explain to someone who doesn't program.




Do you have anything in the criteria of the queries?
 
M

Mark A. Sam

No, becuase every combo will have a list to display, but not filtered.
Unless you have a value in one combo, the combo next to it doesn't need a
criteria. Let us say that none of the combo's have an entry. Then they all
have lists to display. C3 won't be filtered until there is a value in C2.
It won't need to be. There won't be any value to use. Does that make
sense?

What you seem to be suggesting is that each combo is filtered by the one to
its left and if you enter a value into C1 then all of the lists can be
populated, but since C1 is the only combo with a value, then it would only
make sense to apply a criteria to C2.



Adam said:
Mark,
Wouldn't that method still only allow me to go forwards through the combo
boxes? (1 to 2, 2 to 3; or start with 2 then to 3, 3 to 4, etc.) Through
the
4 different posts i have throughout these forums, i've nearly given up on
what i need being possible (without writing endless amounts of codes for
going every which way through 13 combo boxes.)

I really appreciate all the feedback i have gotten though, none the less,
and ive learned visual basic isnt too scary to attempt.





Mark A. Sam said:
Adam,

You now have 4 combo boxes. Let's call them C1,C2,C3 and C4 from left to
right. Iniailly, none should have any criteria so that all of the
selections display in each combo.

If you select a value for C1 then only C2's rowsource needs to be
updated,
because only it will look at C1 for its filtering. C1 filters C2 and
only
C2.

If you select a value for C2 then C3 and only C3's rowsource needs to be
updated. Of if you select a value for C3 and not C2, then only C4'
Rowsource needs to be changed.

For any selection, you only need to update the rowsource of the combo to
the
right of the selected combo.

What you seem to be doing is updating the rowsource of multiple combos.
I
hope that makes sense.

God Bless,

Mark


Adam said:
I think im having a problem understanding the logic behind this, sorry.
But
the post you said i did wrong, why is it not necessary to assign the
rowsource under the "If IsNull" part like this:

Private Sub Rig_Name_AfterUpdate()
If IsNull(Me.ActiveControl) Then
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[RIG HEADING].RowSource = "SELECT MODU.MOORING_TYPE,
MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[MOORING TYPE].RowSource = "SELECT MODU.MOORING_TYPE,
MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _


The way i understand this is, it is saying that if the Rig Name box is
empty, then the [owner], [rig heading], and [mooring type] combo boxes
get
their values from the table. And since i would like to go in a random
order
through my boxes, i would have thought that its necessary to have all
rowsource values assigned there.

Does my logic make sense at all? Or how should the code be read to make
sense to me?

Also, i have not gotten my form to work yet sadly.



:

No that's wrong. You are trying to assign the rowsource for all of
the
combo boxes. It is like this, where you are only setting the
Rowsource
from
[Owner] if [Rig] gets a value.

Private Sub Rig_Name_AfterUpdate()
If IsNull(Me.ActiveControl) Then
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
"From MODU " & _
"WHERE MODU.RIG_NAME= '" & [Forms]![MODULIST]![RIG NAME] & "';"
Else
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"
End If
End Sub


If [Owner] gets a value, then set the Rowsource for [Rig Heading],
etc.


Not too sure if i am doing this correctly, but thats why i'm here.

Ive knocked down my 13 combo boxes i need to have down to 4, just to
simplify this until i figure it out, but my combo boxes are:
[Rig Name]
[Owner]
[Rig Heading]
[Mooring Type]

My table is named MODU

and here is what i put into the after update box from what you had
posted
(with added nonsense, im sure, since im not into coding)

Private Sub Rig_Name_AfterUpdate()
If IsNull(Me.ActiveControl) Then
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[RIG HEADING].RowSource = "SELECT MODU.MOORING_TYPE,
MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
[MOORING TYPE].RowSource = "SELECT MODU.MOORING_TYPE,
MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME " & _
"From MODU " & _
"WHERE MODU.RIG_NAME= '" & [Forms]![MODULIST]![RIG NAME] & "';"
Else
[OWNER].RowSource = "SELECT MODU.MOORING_TYPE, MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"
[RIG HEADING].RowSource = "SELECT MODU.MOORING_TYPE,
MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"
[MOORING TYPE].RowSource = "SELECT MODU.MOORING_TYPE,
MODU.RIG_HEADING,
MODU.OWNER, MODU.RIG_NAME FROM MODU;"

End If
End Sub




:

Disregard my last question. I reread your post and see that you
are
narrowing each combo list down.

I have never been able to figure out an expression that will allow
all
values to be shown if there is nothing in the criteria field. I'm
not
sure
why it isn't allowed. The best way I could see to approach this is
the
allow all the whole list to be displayed and reset the the
rowsource
of
the
following combo whenever you select from any combo. It isn't
difficult
to
do, but difficult to explain to someone who doesn't program.




Do you have anything in the criteria of the queries?
 

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