473,246 Members | 1,507 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,246 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 2838
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: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.