Autofill (1 Viewer)

Status
Not open for further replies.

TPS

Banned
Local time
Today, 00:16
Joined
Oct 1, 2019
Messages
64
It needs to be prefixed with:
Parent.
Or
Forms!NameOfMaimForm.

Neither work. The subform doesn't get updated with any changes that is made on the main form.

=Parent.[Product_Group_Code].[column](1)
or
=Forms![frm_Publisher_Setup].[Product_Group_Code].[column](1)

The unbound combobox on the main form DOES get updated with =Parent.[Product_Group_Code].[column](1) but this isn't what I want. I want it to work on the subform.
 

TPS

Banned
Local time
Today, 00:16
Joined
Oct 1, 2019
Messages
64
Check the name property of the combo box

If I understood this correctly, I should be using the name of combobox on the main form, =Parent.[Product_Group_Code].[column](1)?

Which is correct.
 

TPS

Banned
Local time
Today, 00:16
Joined
Oct 1, 2019
Messages
64
Yes. But what is the name of the combo box

Which one? I think this is where I am getting confused.

Are you asking for the name of the combobox on the MAIN form which is Product_Group_Code or the one on the SUBFORM which is Product_Group.

Product_Group on the subform should update whenever Product_Group_Code on the main form is changed.
 

bob fitz

AWF VIP
Local time
Today, 00:16
Joined
May 23, 2011
Messages
4,719
I'm after the name of the combo box on the main form. It's name my not be the same as the field that it is bound to.6
 

TPS

Banned
Local time
Today, 00:16
Joined
Oct 1, 2019
Messages
64
I'm after the name of the combo box on the main form. It's name my not be the same as the field that it is bound to.6

Which I said in my previous post:

Are you asking for the name of the combobox on the MAIN form which is Product_Group_Code or the one on the SUBFORM which is Product_Group.

Product_Group on the subform should update whenever Product_Group_Code on the main form is changed.

For the record, I got the name by right clicking on the box and then clicking on properties and copying and pasting what is in the Name box.
 

bob fitz

AWF VIP
Local time
Today, 00:16
Joined
May 23, 2011
Messages
4,719
I am not at my computer until I get home this evening but if you post a copy of your db I'd be happy to look at it then.
 

Minty

AWF VIP
Local time
Today, 00:16
Joined
Jul 26, 2013
Messages
10,366
Actually I have just tried this and can confirm that it doesn't appear to work as expected. Which is weird, as I'm convinced I've used the approach before.

Will report back once I've dug into it a bit more.

You can set it from the main form current event or after update event, but that seems clunky by comparison, especially if you want to see it in multiple subforms.
 

TPS

Banned
Local time
Today, 00:16
Joined
Oct 1, 2019
Messages
64
Thanks all. I'm trying a few methods on my end too, so if I can get it to work, I'll report back.
 

TPS

Banned
Local time
Today, 00:16
Joined
Oct 1, 2019
Messages
64
I've managed to get it somewhat working, with this code (using the expression builder)

=[Forms]![frm_Publisher_Setup]![Product_Group_Code].[Column](1)

When adding in a new record, I can make the selection on the main page and it will auto update the subform, which is good, but say for example a mistake has been made and the wrong product group has been selected. The main form can be changed, but the subform won't be updated with that new change. It will only record the first selection.

So, part way there.
 

bob fitz

AWF VIP
Local time
Today, 00:16
Joined
May 23, 2011
Messages
4,719
Perhaps you need to Requery the control on the sub form in the AfterUpdate event of the combo on the main form
 

TPS

Banned
Local time
Today, 00:16
Joined
Oct 1, 2019
Messages
64
Perhaps you need to Requery the control on the sub form in the AfterUpdate event of the combo on the main form

I assume you mean use the same code which is

=[Forms]![frm_Publisher_Setup]![Product_Group_Code].[Column](1)

In the After Update section within Property, if so, this didn't work unfortunately.
 

bob fitz

AWF VIP
Local time
Today, 00:16
Joined
May 23, 2011
Messages
4,719
No. What I meant was something like:

Me.NameOfSubForm.Form.NameOfTextbox.Requery

In the AfterUpdate event of the combo box.

Alternatively, you could try:

Me.NameOfSubForm.Requery
 

TPS

Banned
Local time
Today, 00:16
Joined
Oct 1, 2019
Messages
64
No. What I meant was something like:

Me.NameOfSubForm.Form.NameOfTextbox.Requery

In the AfterUpdate event of the combo box.

Alternatively, you could try:

Me.NameOfSubForm.Requery

Neither work unfortunately.
 

bob fitz

AWF VIP
Local time
Today, 00:16
Joined
May 23, 2011
Messages
4,719
Can you check that the code does actually run using a breakpoint or perhaps insert a msgbox into the code
 

TPS

Banned
Local time
Today, 00:16
Joined
Oct 1, 2019
Messages
64
Can you check that the code does actually run using a breakpoint or perhaps insert a msgbox into the code

Being a noob to all of this. I'm not using VB, if that's what you're asking. I'm making the changes here, then testing by changing the main product group drop down to another and seeing that it's not updating on the subform.



I've taken the AfterEvent code out for now and trying different things.
 

bob fitz

AWF VIP
Local time
Today, 00:16
Joined
May 23, 2011
Messages
4,719
You need to put the code into the events procedure.
So, click the arrow down and select
Event Procedure.
Then click the button next to the down button with the three dots ...
This will open the forms code module.
Enter the code given earlier, immediately above the line that says
End Sub
 

TPS

Banned
Local time
Today, 00:16
Joined
Oct 1, 2019
Messages
64
You need to put the code into the events procedure.
So, click the arrow down and select
Event Procedure.
Then click the button next to the down button with the three dots ...
This will open the forms code module.
Enter the code given earlier, immediately above the line that says
End Sub

Doesn't work I'm afraid. I did what you said, then went back to Form View, clicked on the Product Group drop down on the main form, changed it to another selection and the subform did not update.
 

Gasman

Enthusiastic Amateur
Local time
Today, 00:16
Joined
Sep 21, 2011
Messages
14,231
'Doesn't work' is as much use as a chocolate fireguard.:(

Please explain in detail exactly what you have entered into the afterupdate event.
Do not retype it, copy and paste all of the code with code tags by using the # icon when making the post.
Alternatively upload your DB, zip it if it is too big to do as a accdb.
 
Status
Not open for further replies.

Users who are viewing this thread

Top Bottom