synchronized combo boxes moving between records problem

G

Guest

Sorry if this has been answered, I couldn't find the exact problem elsewhere!
I'm only a beginner at this but when i select the right ID from the first
combo box, i got it to come up with the correct related IDs in the second
combo box , like it's meant to! but when I move to the next record (a new
one, or the last one, or anything), the second combo box doesn't retain the
record.
As in, as you scroll through each record, none of the second combo box
'records' are kept, they are all blank until you click on them, then they
come up with your choices,
UNLESS you go to a record that has the same first combo box ID selected as
whatever you last clicked on .
I'm sure that is all very unclear now!

Perhaps to give you a better idea- the form is a record of payments, first
combo (combo 17) has the payor, second combo (combo26) has the child they're
paying for, each new record is a payment.

I originally used some knowledge base article to first do it, but think I
had to modify something anyway.

Here's the code for the boxes after update and current as it looks now.

Private Sub Combo17_AfterUpdate()
Me!Combo26.Requery
Me!Combo26.SetFocus
End Sub

Private Sub Form_Current()
Me.Combo26.Requery
End Sub

The row source for the 2nd combo is based on a query with this criteria
(also based on the article)

IIf(IsNull([Forms]![Sponsorship Payments Form]![Combo17]),[Sponsor
ID],[Forms]![Sponsorship Payments Form]![Combo17])

i've messed around with it so much trying so many ways to fix it that i
can't remember what it originally looked like! but i still had the same
problem

Please can anybody help? I can't figure out what to do.
The really bugging thing is that I (THINK) I had it working for a while
(possibly), but I might have had to do something different from the article,
but I can't remember?! and while I was messing around trying to get something
else 2 work, it stopped doing what it was meant to do. (and wouldn't you know
it my backups all became useless for various reasons).
 
G

Guest

You fail to tell us what these two combo boxes are supposed to do and whether
they are bound to your form. Are they just values for the form, or do they
filter the form?

First. You really should establish a naming convention for your controls.
Don't settle for what Access provides you. Name them something that is
meaningful so that when you actually look at the code, you can easily tell
what control you are on.
That said, I'll call Combo17 cbo_Payor and Combo26 cbo_Child. I preface all
text boxes with 'txt_' and then either the field name of a descriptor.
Labels are 'lbl_', listboxes are 'lst_', option groups are 'og_', radio
buttons are 'rb_', check boxes are 'chk_', ... This makes your code
so.............. much easier to read.

It would appear that the cbo_Payor should be bound to your [Sponsor_ID]
field, is it, or do you have a Payor_ID field? If not, what is that combo
box bound to?

What is the entire SQL for the row source for cbo_Child? What data field is
this control bound to?

Dale




--
Email address is not valid.
Please reply to newsgroup only.


sezmaz said:
Sorry if this has been answered, I couldn't find the exact problem elsewhere!
I'm only a beginner at this but when i select the right ID from the first
combo box, i got it to come up with the correct related IDs in the second
combo box , like it's meant to! but when I move to the next record (a new
one, or the last one, or anything), the second combo box doesn't retain the
record.
As in, as you scroll through each record, none of the second combo box
'records' are kept, they are all blank until you click on them, then they
come up with your choices,
UNLESS you go to a record that has the same first combo box ID selected as
whatever you last clicked on .
I'm sure that is all very unclear now!

Perhaps to give you a better idea- the form is a record of payments, first
combo (combo 17) has the payor, second combo (combo26) has the child they're
paying for, each new record is a payment.

I originally used some knowledge base article to first do it, but think I
had to modify something anyway.

Here's the code for the boxes after update and current as it looks now.

Private Sub Combo17_AfterUpdate()
Me!Combo26.Requery
Me!Combo26.SetFocus
End Sub

Private Sub Form_Current()
Me.Combo26.Requery
End Sub

The row source for the 2nd combo is based on a query with this criteria
(also based on the article)

IIf(IsNull([Forms]![Sponsorship Payments Form]![Combo17]),[Sponsor
ID],[Forms]![Sponsorship Payments Form]![Combo17])

i've messed around with it so much trying so many ways to fix it that i
can't remember what it originally looked like! but i still had the same
problem

Please can anybody help? I can't figure out what to do.
The really bugging thing is that I (THINK) I had it working for a while
(possibly), but I might have had to do something different from the article,
but I can't remember?! and while I was messing around trying to get something
else 2 work, it stopped doing what it was meant to do. (and wouldn't you know
it my backups all became useless for various reasons).
 
G

Guest

Thanks for replying, I didn't reply sooner bcos I was off work last week.

OK. I'll try to answer. Please forgive any ignorance on my part.

The payor combo box is based on an ID field (sponsor ID) in another table
(sponsor details) and each record is meant to reflect a payment for a child
(some have more than one), hence i scroll for the payor, and then want the
second combo (child combo box) to only display the children that 'belong' to
that sponsor.
I mentioned that the child combo is based on a query but forgot to mention
that the query is based on a 3rd table which records which sponsors belong to
which children (and the child IDs come from a separate child details table).
I had to have the third child/sponsor table bcos a lot of sponsors have more
than one child, and some children have more than one sponsor.

I changed the names like you suggested, so they are now cbo_sponsor and
cbo_child
So the query that cbo_child is based on now has this in it:

IIf(IsNull([Forms]![Sponsorship Payments Form]![cbo_sponsor]),[Sponsor
ID],[Forms]![Sponsorship Payments Form]![cbo_sponsor])

Is that any clearer now? I hope I answered everything.

Thanks heaps,

Sarah


Dale Fye said:
You fail to tell us what these two combo boxes are supposed to do and whether
they are bound to your form. Are they just values for the form, or do they
filter the form?

First. You really should establish a naming convention for your controls.
Don't settle for what Access provides you. Name them something that is
meaningful so that when you actually look at the code, you can easily tell
what control you are on.
That said, I'll call Combo17 cbo_Payor and Combo26 cbo_Child. I preface all
text boxes with 'txt_' and then either the field name of a descriptor.
Labels are 'lbl_', listboxes are 'lst_', option groups are 'og_', radio
buttons are 'rb_', check boxes are 'chk_', ... This makes your code
so.............. much easier to read.

It would appear that the cbo_Payor should be bound to your [Sponsor_ID]
field, is it, or do you have a Payor_ID field? If not, what is that combo
box bound to?

What is the entire SQL for the row source for cbo_Child? What data field is
this control bound to?

Dale




--
Email address is not valid.
Please reply to newsgroup only.


sezmaz said:
Sorry if this has been answered, I couldn't find the exact problem elsewhere!
I'm only a beginner at this but when i select the right ID from the first
combo box, i got it to come up with the correct related IDs in the second
combo box , like it's meant to! but when I move to the next record (a new
one, or the last one, or anything), the second combo box doesn't retain the
record.
As in, as you scroll through each record, none of the second combo box
'records' are kept, they are all blank until you click on them, then they
come up with your choices,
UNLESS you go to a record that has the same first combo box ID selected as
whatever you last clicked on .
I'm sure that is all very unclear now!

Perhaps to give you a better idea- the form is a record of payments, first
combo (combo 17) has the payor, second combo (combo26) has the child they're
paying for, each new record is a payment.

I originally used some knowledge base article to first do it, but think I
had to modify something anyway.

Here's the code for the boxes after update and current as it looks now.

Private Sub Combo17_AfterUpdate()
Me!Combo26.Requery
Me!Combo26.SetFocus
End Sub

Private Sub Form_Current()
Me.Combo26.Requery
End Sub

The row source for the 2nd combo is based on a query with this criteria
(also based on the article)

IIf(IsNull([Forms]![Sponsorship Payments Form]![Combo17]),[Sponsor
ID],[Forms]![Sponsorship Payments Form]![Combo17])

i've messed around with it so much trying so many ways to fix it that i
can't remember what it originally looked like! but i still had the same
problem

Please can anybody help? I can't figure out what to do.
The really bugging thing is that I (THINK) I had it working for a while
(possibly), but I might have had to do something different from the article,
but I can't remember?! and while I was messing around trying to get something
else 2 work, it stopped doing what it was meant to do. (and wouldn't you know
it my backups all became useless for various reasons).
 
G

Guest

Some help, anybody??

sezmaz said:
Thanks for replying, I didn't reply sooner bcos I was off work last week.

OK. I'll try to answer. Please forgive any ignorance on my part.

The payor combo box is based on an ID field (sponsor ID) in another table
(sponsor details) and each record is meant to reflect a payment for a child
(some have more than one), hence i scroll for the payor, and then want the
second combo (child combo box) to only display the children that 'belong' to
that sponsor.
I mentioned that the child combo is based on a query but forgot to mention
that the query is based on a 3rd table which records which sponsors belong to
which children (and the child IDs come from a separate child details table).
I had to have the third child/sponsor table bcos a lot of sponsors have more
than one child, and some children have more than one sponsor.

I changed the names like you suggested, so they are now cbo_sponsor and
cbo_child
So the query that cbo_child is based on now has this in it:

IIf(IsNull([Forms]![Sponsorship Payments Form]![cbo_sponsor]),[Sponsor
ID],[Forms]![Sponsorship Payments Form]![cbo_sponsor])

Is that any clearer now? I hope I answered everything.

Thanks heaps,

Sarah


Dale Fye said:
You fail to tell us what these two combo boxes are supposed to do and whether
they are bound to your form. Are they just values for the form, or do they
filter the form?

First. You really should establish a naming convention for your controls.
Don't settle for what Access provides you. Name them something that is
meaningful so that when you actually look at the code, you can easily tell
what control you are on.
That said, I'll call Combo17 cbo_Payor and Combo26 cbo_Child. I preface all
text boxes with 'txt_' and then either the field name of a descriptor.
Labels are 'lbl_', listboxes are 'lst_', option groups are 'og_', radio
buttons are 'rb_', check boxes are 'chk_', ... This makes your code
so.............. much easier to read.

It would appear that the cbo_Payor should be bound to your [Sponsor_ID]
field, is it, or do you have a Payor_ID field? If not, what is that combo
box bound to?

What is the entire SQL for the row source for cbo_Child? What data field is
this control bound to?

Dale




--
Email address is not valid.
Please reply to newsgroup only.


sezmaz said:
Sorry if this has been answered, I couldn't find the exact problem elsewhere!
I'm only a beginner at this but when i select the right ID from the first
combo box, i got it to come up with the correct related IDs in the second
combo box , like it's meant to! but when I move to the next record (a new
one, or the last one, or anything), the second combo box doesn't retain the
record.
As in, as you scroll through each record, none of the second combo box
'records' are kept, they are all blank until you click on them, then they
come up with your choices,
UNLESS you go to a record that has the same first combo box ID selected as
whatever you last clicked on .
I'm sure that is all very unclear now!

Perhaps to give you a better idea- the form is a record of payments, first
combo (combo 17) has the payor, second combo (combo26) has the child they're
paying for, each new record is a payment.

I originally used some knowledge base article to first do it, but think I
had to modify something anyway.

Here's the code for the boxes after update and current as it looks now.

Private Sub Combo17_AfterUpdate()
Me!Combo26.Requery
Me!Combo26.SetFocus
End Sub

Private Sub Form_Current()
Me.Combo26.Requery
End Sub

The row source for the 2nd combo is based on a query with this criteria
(also based on the article)

IIf(IsNull([Forms]![Sponsorship Payments Form]![Combo17]),[Sponsor
ID],[Forms]![Sponsorship Payments Form]![Combo17])

i've messed around with it so much trying so many ways to fix it that i
can't remember what it originally looked like! but i still had the same
problem

Please can anybody help? I can't figure out what to do.
The really bugging thing is that I (THINK) I had it working for a while
(possibly), but I might have had to do something different from the article,
but I can't remember?! and while I was messing around trying to get something
else 2 work, it stopped doing what it was meant to do. (and wouldn't you know
it my backups all became useless for various reasons).
 

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