By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,654 Members | 1,840 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,654 IT Pros & Developers. It's quick & easy.

Populating One Dropdown based on the Results of Another

P: n/a
Group,

I'm having a tough time understanding some of the previous posts on
this topic so I wanted to write what I've tried and hope that you can
help me troubleshoot. I have a dropdown populated from a table and I
want to take that selection and use it to populate the next dropdown.
So far:

1) I tried using a query that said select specificissue from
specific_issue and used as my criterion [Form]![Report]![IssueCategory]
but that didn't seem to populate the 2nd dropdown. (Rowsource type was
query)

2) I tried on the On Exit command of the first combo box to use this
statement to populate the second combo box
([OtherCombo].RowSource = "Select AttendYear from YourTableName Where
YourTableName.Event = " & Me.ThisComboName)

3)I've also clicked every button in Access

All help will be appreciated,

Thanks in advance,
Melih

Nov 13 '05 #1
Share this Question
Share on Google+
13 Replies


P: n/a
I would have expected #2 to work. #1 will work, but you have to issue a
Requery to the second combo box. In #2, since you are changing the
RowSource, the combo box should automatically requery.

Example:
Me.OtherCombo.Requery

One possible problem, if the combo box has the same name as the field it is
bound to, your code is a little ambiguous. Try changing #2 to

Me.OtherCombo.RowSource = "Select AttendYear from YourTableName Where
YourTableName.Event = " & Me.ThisComboName & ";"

Also, what is the value being returned by Me.ThisComboName? Is it a number
or a text string? The syntax is correct for a number, if it is a text
string, modify the above line to:

Me.OtherCombo.RowSource = "Select AttendYear from YourTableName Where
YourTableName.Event = """ & Me.ThisComboName & """;"

--
Wayne Morgan
MS Access MVP
<me***********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Group,

I'm having a tough time understanding some of the previous posts on
this topic so I wanted to write what I've tried and hope that you can
help me troubleshoot. I have a dropdown populated from a table and I
want to take that selection and use it to populate the next dropdown.
So far:

1) I tried using a query that said select specificissue from
specific_issue and used as my criterion [Form]![Report]![IssueCategory]
but that didn't seem to populate the 2nd dropdown. (Rowsource type was
query)

2) I tried on the On Exit command of the first combo box to use this
statement to populate the second combo box
([OtherCombo].RowSource = "Select AttendYear from YourTableName Where
YourTableName.Event = " & Me.ThisComboName)

3)I've also clicked every button in Access

All help will be appreciated,

Thanks in advance,
Melih

Nov 13 '05 #2

P: n/a
Wayne & Group,

I tried your solution again. The error I get says that it can't find
the macro that I'm using to get the data. The error I think is what's
confusing me because I didn't think I was using a macro. Thanks for
your help,

Melih

Wayne Morgan wrote:
I would have expected #2 to work. #1 will work, but you have to issue a
Requery to the second combo box. In #2, since you are changing the
RowSource, the combo box should automatically requery.

Example:
Me.OtherCombo.Requery

One possible problem, if the combo box has the same name as the field it is
bound to, your code is a little ambiguous. Try changing #2 to

Me.OtherCombo.RowSource = "Select AttendYear from YourTableName Where
YourTableName.Event = " & Me.ThisComboName & ";"

Also, what is the value being returned by Me.ThisComboName? Is it a number
or a text string? The syntax is correct for a number, if it is a text
string, modify the above line to:

Me.OtherCombo.RowSource = "Select AttendYear from YourTableName Where
YourTableName.Event = """ & Me.ThisComboName & """;"

--
Wayne Morgan
MS Access MVP
<me***********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Group,

I'm having a tough time understanding some of the previous posts on
this topic so I wanted to write what I've tried and hope that you can
help me troubleshoot. I have a dropdown populated from a table and I
want to take that selection and use it to populate the next dropdown.
So far:

1) I tried using a query that said select specificissue from
specific_issue and used as my criterion [Form]![Report]![IssueCategory]
but that didn't seem to populate the 2nd dropdown. (Rowsource type was
query)

2) I tried on the On Exit command of the first combo box to use this
statement to populate the second combo box
([OtherCombo].RowSource = "Select AttendYear from YourTableName Where
YourTableName.Event = " & Me.ThisComboName)

3)I've also clicked every button in Access

All help will be appreciated,

Thanks in advance,
Melih


Nov 13 '05 #3

P: n/a
Wayne & Group,

I tried your solution again. The error I get says that it can't find
the macro that I'm using to get the data. The error I think is what's
confusing me because I didn't think I was using a macro. Thanks for
your help,

Melih

Wayne Morgan wrote:
I would have expected #2 to work. #1 will work, but you have to issue a
Requery to the second combo box. In #2, since you are changing the
RowSource, the combo box should automatically requery.

Example:
Me.OtherCombo.Requery

One possible problem, if the combo box has the same name as the field it is
bound to, your code is a little ambiguous. Try changing #2 to

Me.OtherCombo.RowSource = "Select AttendYear from YourTableName Where
YourTableName.Event = " & Me.ThisComboName & ";"

Also, what is the value being returned by Me.ThisComboName? Is it a number
or a text string? The syntax is correct for a number, if it is a text
string, modify the above line to:

Me.OtherCombo.RowSource = "Select AttendYear from YourTableName Where
YourTableName.Event = """ & Me.ThisComboName & """;"

--
Wayne Morgan
MS Access MVP
<me***********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Group,

I'm having a tough time understanding some of the previous posts on
this topic so I wanted to write what I've tried and hope that you can
help me troubleshoot. I have a dropdown populated from a table and I
want to take that selection and use it to populate the next dropdown.
So far:

1) I tried using a query that said select specificissue from
specific_issue and used as my criterion [Form]![Report]![IssueCategory]
but that didn't seem to populate the 2nd dropdown. (Rowsource type was
query)

2) I tried on the On Exit command of the first combo box to use this
statement to populate the second combo box
([OtherCombo].RowSource = "Select AttendYear from YourTableName Where
YourTableName.Event = " & Me.ThisComboName)

3)I've also clicked every button in Access

All help will be appreciated,

Thanks in advance,
Melih


Nov 13 '05 #4

P: n/a
Also, is Me the equivalent to this in an object-oriented language? Or
should Me be something that I've already created?

Melih

Nov 13 '05 #5

P: n/a
Also, is Me the equivalent to this in an object-oriented language? Or
should Me be something that I've already created?

Melih

Nov 13 '05 #6

P: n/a
I'm not familiar with "this". "Me" is shorthand for the form or report on
which the code is running. If the form is called frmMyForm, you would refer
to it as Forms!frmMyForm. However, if the code is in the frmMyForm's module,
you can simply say Me instead of Forms!frmMyForm.

--
Wayne Morgan
MS Access MVP
<me***********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Also, is Me the equivalent to this in an object-oriented language? Or
should Me be something that I've already created?

Melih

Nov 13 '05 #7

P: n/a
Please post the entire On Exit event from the VBA editor. Also, in the
form's Properties sheet, the On Exit should be set to [Event Procedure],
next click the ... button to the right to open the VBA editor at this event.
The first and last line of the event will already be filled in for you.

--
Wayne Morgan
MS Access MVP
<me***********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Wayne & Group,

I tried your solution again. The error I get says that it can't find
the macro that I'm using to get the data. The error I think is what's
confusing me because I didn't think I was using a macro. Thanks for
your help,

Melih

Wayne Morgan wrote:
I would have expected #2 to work. #1 will work, but you have to issue a
Requery to the second combo box. In #2, since you are changing the
RowSource, the combo box should automatically requery.

Example:
Me.OtherCombo.Requery

One possible problem, if the combo box has the same name as the field it
is
bound to, your code is a little ambiguous. Try changing #2 to

Me.OtherCombo.RowSource = "Select AttendYear from YourTableName Where
YourTableName.Event = " & Me.ThisComboName & ";"

Also, what is the value being returned by Me.ThisComboName? Is it a
number
or a text string? The syntax is correct for a number, if it is a text
string, modify the above line to:

Me.OtherCombo.RowSource = "Select AttendYear from YourTableName Where
YourTableName.Event = """ & Me.ThisComboName & """;"

--
Wayne Morgan
MS Access MVP
<me***********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
> Group,
>
> I'm having a tough time understanding some of the previous posts on
> this topic so I wanted to write what I've tried and hope that you can
> help me troubleshoot. I have a dropdown populated from a table and I
> want to take that selection and use it to populate the next dropdown.
> So far:
>
> 1) I tried using a query that said select specificissue from
> specific_issue and used as my criterion [Form]![Report]![IssueCategory]
> but that didn't seem to populate the 2nd dropdown. (Rowsource type was
> query)
>
> 2) I tried on the On Exit command of the first combo box to use this
> statement to populate the second combo box
> ([OtherCombo].RowSource = "Select AttendYear from YourTableName Where
> YourTableName.Event = " & Me.ThisComboName)
>
> 3)I've also clicked every button in Access
>
> All help will be appreciated,
>
> Thanks in advance,
> Melih
>

Nov 13 '05 #8

P: n/a
I'm not familiar with "this". "Me" is shorthand for the form or report on
which the code is running. If the form is called frmMyForm, you would refer
to it as Forms!frmMyForm. However, if the code is in the frmMyForm's module,
you can simply say Me instead of Forms!frmMyForm.

--
Wayne Morgan
MS Access MVP
<me***********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Also, is Me the equivalent to this in an object-oriented language? Or
should Me be something that I've already created?

Melih

Nov 13 '05 #9

P: n/a
Please post the entire On Exit event from the VBA editor. Also, in the
form's Properties sheet, the On Exit should be set to [Event Procedure],
next click the ... button to the right to open the VBA editor at this event.
The first and last line of the event will already be filled in for you.

--
Wayne Morgan
MS Access MVP
<me***********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Wayne & Group,

I tried your solution again. The error I get says that it can't find
the macro that I'm using to get the data. The error I think is what's
confusing me because I didn't think I was using a macro. Thanks for
your help,

Melih

Wayne Morgan wrote:
I would have expected #2 to work. #1 will work, but you have to issue a
Requery to the second combo box. In #2, since you are changing the
RowSource, the combo box should automatically requery.

Example:
Me.OtherCombo.Requery

One possible problem, if the combo box has the same name as the field it
is
bound to, your code is a little ambiguous. Try changing #2 to

Me.OtherCombo.RowSource = "Select AttendYear from YourTableName Where
YourTableName.Event = " & Me.ThisComboName & ";"

Also, what is the value being returned by Me.ThisComboName? Is it a
number
or a text string? The syntax is correct for a number, if it is a text
string, modify the above line to:

Me.OtherCombo.RowSource = "Select AttendYear from YourTableName Where
YourTableName.Event = """ & Me.ThisComboName & """;"

--
Wayne Morgan
MS Access MVP
<me***********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
> Group,
>
> I'm having a tough time understanding some of the previous posts on
> this topic so I wanted to write what I've tried and hope that you can
> help me troubleshoot. I have a dropdown populated from a table and I
> want to take that selection and use it to populate the next dropdown.
> So far:
>
> 1) I tried using a query that said select specificissue from
> specific_issue and used as my criterion [Form]![Report]![IssueCategory]
> but that didn't seem to populate the 2nd dropdown. (Rowsource type was
> query)
>
> 2) I tried on the On Exit command of the first combo box to use this
> statement to populate the second combo box
> ([OtherCombo].RowSource = "Select AttendYear from YourTableName Where
> YourTableName.Event = " & Me.ThisComboName)
>
> 3)I've also clicked every button in Access
>
> All help will be appreciated,
>
> Thanks in advance,
> Melih
>

Nov 13 '05 #10

P: n/a
"Wayne Morgan" <co***************************@hotmail.com> wrote in
news:8g****************@newssvr19.news.prodigy.com :
I'm not familiar with "this". "Me" is shorthand for the form or
report on which the code is running. . . .
Actually, I think "Me" refers to the class object you're working in.
That's why it works in a standalone class module, since it's a class
object that's unattached to a form or report.
. . . If the form is called
frmMyForm, you would refer to it as Forms!frmMyForm. However, if
the code is in the frmMyForm's module, you can simply say Me
instead of Forms!frmMyForm.


Likewise, when you need to write modular code to act on multiple
forms, you can use the Me keyword to pass a form reference to the
external code. If your external code works like this:

Public Sub SetUpForm(frm As Form)
frm.Detail(0).BackGroundColor = 0
[and so forth]
End Sub

You'd call it in the form as:

Call SetupForm(Me)

or simply:

SetupForm Me

(I prefer to use Call to show that it's a call to external code, not
a standalone Access command)

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #11

P: n/a
"Wayne Morgan" <co***************************@hotmail.com> wrote in
news:8g****************@newssvr19.news.prodigy.com :
I'm not familiar with "this". "Me" is shorthand for the form or
report on which the code is running. . . .
Actually, I think "Me" refers to the class object you're working in.
That's why it works in a standalone class module, since it's a class
object that's unattached to a form or report.
. . . If the form is called
frmMyForm, you would refer to it as Forms!frmMyForm. However, if
the code is in the frmMyForm's module, you can simply say Me
instead of Forms!frmMyForm.


Likewise, when you need to write modular code to act on multiple
forms, you can use the Me keyword to pass a form reference to the
external code. If your external code works like this:

Public Sub SetUpForm(frm As Form)
frm.Detail(0).BackGroundColor = 0
[and so forth]
End Sub

You'd call it in the form as:

Call SetupForm(Me)

or simply:

SetupForm Me

(I prefer to use Call to show that it's a call to external code, not
a standalone Access command)

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #12

P: n/a

me***********@gmail.com wrote:
Group,

I'm having a tough time understanding some of the previous posts on
this topic so I wanted to write what I've tried and hope that you can
help me troubleshoot. I have a dropdown populated from a table and I
want to take that selection and use it to populate the next dropdown.
So far:

1) I tried using a query that said select specificissue from
specific_issue and used as my criterion [Form]![Report]![IssueCategory]
but that didn't seem to populate the 2nd dropdown. (Rowsource type was
query)

2) I tried on the On Exit command of the first combo box to use this
statement to populate the second combo box
([OtherCombo].RowSource = "Select AttendYear from YourTableName Where
YourTableName.Event = " & Me.ThisComboName)

3)I've also clicked every button in Access

All help will be appreciated,

Thanks in advance,
Melih


You have a dropdown where you select a specific field and want to use it to
populate the next dropdown?
1) Your first dropdown should be unbound, and should have a name (go to
properties, other, name).

2) create a second dropdown also unbound, make sure to include the field that
you are selecting in the first dropdown. Also should have a name.
go to propereties and in RowSource click on ... (ellipses).
under the field selected in the first dropdown: Criteria:[first
dropdown name].[value]

3) Make a Macro: RequerySecondDropdown. Action: Requery

Control Name: Second Dropdown Name

4) First Dropdown go to properties: Event: OnClick: RequerySecondDropdown

I hope this help Mehli, Good luck
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200507/1
Nov 13 '05 #13

P: n/a

me***********@gmail.com wrote:
Group,

I'm having a tough time understanding some of the previous posts on
this topic so I wanted to write what I've tried and hope that you can
help me troubleshoot. I have a dropdown populated from a table and I
want to take that selection and use it to populate the next dropdown.
So far:

1) I tried using a query that said select specificissue from
specific_issue and used as my criterion [Form]![Report]![IssueCategory]
but that didn't seem to populate the 2nd dropdown. (Rowsource type was
query)

2) I tried on the On Exit command of the first combo box to use this
statement to populate the second combo box
([OtherCombo].RowSource = "Select AttendYear from YourTableName Where
YourTableName.Event = " & Me.ThisComboName)

3)I've also clicked every button in Access

All help will be appreciated,

Thanks in advance,
Melih


You have a dropdown where you select a specific field and want to use it to
populate the next dropdown?
1) Your first dropdown should be unbound, and should have a name (go to
properties, other, name).

2) create a second dropdown also unbound, make sure to include the field that
you are selecting in the first dropdown. Also should have a name.
go to propereties and in RowSource click on ... (ellipses).
under the field selected in the first dropdown: Criteria:[first
dropdown name].[value]

3) Make a Macro: RequerySecondDropdown. Action: Requery

Control Name: Second Dropdown Name

4) First Dropdown go to properties: Event: OnClick: RequerySecondDropdown

I hope this help Mehli, Good luck
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200507/1
Nov 13 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.