473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Populating One Dropdown based on the Results of Another

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
13 2844
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
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
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
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
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
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
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
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
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
"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
"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

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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Lamine Darbouche | last post by:
Can anybody help? I need to have three list boxes automatically populating each other, (ie when region is selected from the first listbox, it will populate automatically the second one which is...
4
by: JP SIngh | last post by:
I have three dropdowns in one of my asp page. Each dropdown does return a huge amount of records , 5000 to be precise. The huge amount of data makes the page slower to load and also makes it...
3
by: to_rgoyal | last post by:
Hi All, I am creating one web base application using ASP.net and C#. I am populating dropdown lists of my web pages using database. I am using this code: con = new...
1
by: Mike P | last post by:
I am populating a drop down column in a datagrid on page load. Here is my code : <asp:TemplateColumn> <ItemTemplate> <asp:DropDownList ID="ddlUserName" Font-Name="Verdana" Font-Size="8pt"...
2
by: Spartaco | last post by:
I have a dropdown control into a page and a gridview, both are associated to two SqlDataSource controls, one of them is used to fill the DropDownControl, that is meant to be a filter over the query...
4
by: AccessRookie | last post by:
Ok, I am pretty new to Access (Using Access 2002 at my job). Here is what I want to do. I want to create a database that has a form. On this form will be a dropdown menu (combobox). Depending...
0
by: koonda | last post by:
Hi all, I have a Project due after one week. It is a web service project. I have a Web Form which communicates to the web service and this web service communicates to the database. I have all my...
11
by: tokcy | last post by:
Hi everyone, I am new in php and ajax, i am facing the prob while i click on element of first drop down then in second dropdown all element showl come from database. I mean i have three dropdown 1....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.