Autofill (1 Viewer)

Status
Not open for further replies.

TPS

Banned
Local time
Today, 06:37
Joined
Oct 1, 2019
Messages
64
'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.

I did exactly what Bob Fitz said:

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

Code:
Private Sub Combo284_AfterUpdate()
Me.frm_Marketing_Subform.Requery
End Sub

or

Code:
Private Sub Combo284_AfterUpdate()
Me.frm_Marketing_Subform.Form.Combo284.Requery
End Sub
 

TPS

Banned
Local time
Today, 06:37
Joined
Oct 1, 2019
Messages
64
it's just a matter of updating all Subform's product group combo.
on after update event of Product_Group_Code combo on main form:
Code:
private sub product_group_code_afterupdate()
with me.subform1.form
    !product_group = me.product_group_code
    .dirty = false
end with
with me.subform2.form
    !product_group = me.product_group_code
    .dirty = false
end with
…
…
end sub

This works. Thank you, I missed this reply before.
 

bob fitz

AWF VIP
Local time
Today, 06:37
Joined
May 23, 2011
Messages
4,717
I see from the code that you've posted that the combo box is actually named combo284.
I'm not sure that you will need code here if you use that name in the expression you were given yesterday for the text box on the sub form
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:37
Joined
Sep 21, 2011
Messages
14,048
I did exactly what Bob Fitz said:



Code:
Private Sub Combo284_AfterUpdate()
Me.frm_Marketing_Subform.Requery
End Sub

or

Code:
Private Sub Combo284_AfterUpdate()
Me.frm_Marketing_Subform.Form.Combo284.Requery
End Sub

I cannot believe that both combos are called Combo284?
So it appears that you are reuqerying the combo that is being changed.? :confused:
You need to requery the control on the subform FROM the afterupdate event of the control on the mainform, which is what arnelgp had posted.?
 

TPS

Banned
Local time
Today, 06:37
Joined
Oct 1, 2019
Messages
64
I cannot believe that both combos are called Combo284?
So it appears that you are reuqerying the combo that is being changed.? :confused:
You need to requery the control on the subform FROM the afterupdate event of the control on the mainform, which is what arnelgp had posted.?

His code worked but I could get Bob Fitz suggestions to work.

I now need to get a subform to update based on another subform but arnelgp's code doesn't work for that. So I'm trying to figure it out.

I will post my step by step shortly.
 

TPS

Banned
Local time
Today, 06:37
Joined
Oct 1, 2019
Messages
64
On Marketing Template Subform, in Design View, I created an Unbound Combobox called Unbound_BookDiscount.

I set the control source to be:

Code:
Forms![frm_Publisher_Info_Subform]![Book_Discount_Code]

Because when Book Discount Code on the Publisher Info Subform is changed, I want this Unbound control to be changed.

I then went to the Publisher Info Subform and clicked the combobox called Book Discount Code. I clicked on Event and then clicked on After Update and selected Event Procedure. I then clicked on the 3 dots and it opened VBA. I then have this code from Bob Fitz, modified to work in my application:

Code:
Private Sub Book_Discount_Code_AfterUpdate()
Me.frm_Marketing_Subform.Form.Unbound_BookDiscount.Requery
End Sub

Which as I understand it says, When Book Discount Code is updated, requery the combobox Unbound_Book Discount on the Marketing Subform.

Save.

Right click main form and click on Form View and test by changing Book Discount Code on Publisher Info Subform.

I then get the following error:

Code:
Compile Error:
Method or data member not found

VBA then automatically highlights the following:

Code:
.frm_Marketing_Subform

Which from what I understand, is saying the subform name is wrong or not found but it isn't as I copied and pasted this from working code in arnelgp's solution. Arnelgp's solution works fine if I am referencing the main form to a subform.

So what am I doing wrong? Is this now clearer what I am doing and what code I am using, from which contributor and where it's going wrong?
 
Last edited:

bob fitz

AWF VIP
Local time
Today, 06:37
Joined
May 23, 2011
Messages
4,717
In your first post you showed a combo on the sub form. Will users ever change the selection there on the sub form or will that only be done on the main form.
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:37
Joined
Sep 21, 2011
Messages
14,048
His code worked but I could get Bob Fitz suggestions to work.

I now need to get a subform to update based on another subform but arnelgp's code doesn't work for that. So I'm trying to figure it out.

I will post my step by step shortly.

The logic is the same?
 

TPS

Banned
Local time
Today, 06:37
Joined
Oct 1, 2019
Messages
64
In your first post you showed a combo on the sub form. Will users ever change the selection there on the sub form or will that only be done on the main form.

I need to get subforms to link together as mentioned in my step by step.

The logic is the same?

See my step by step? Maybe you can tell me why it doesn't work?
 

bob fitz

AWF VIP
Local time
Today, 06:37
Joined
May 23, 2011
Messages
4,717
I need to get subforms to link together as mentioned in my step by step.



See my step by step? Maybe you can tell me why it doesn't work?
Can you answer the question in my last post please
 

TPS

Banned
Local time
Today, 06:37
Joined
Oct 1, 2019
Messages
64
Can you answer the question in my last post please

I have already in this thread, no, this is the whole purpose to have it locked, so once it's made, it will be made on all iterations of it. However the main form linking to the subform is irrelevant as arnelgps code worked and does that I want.

The issue I have now, is using your code in linking two fields on two different subforms. As said in my step my step, it doesn't work.
 

bob fitz

AWF VIP
Local time
Today, 06:37
Joined
May 23, 2011
Messages
4,717
I have already in this thread, no, this is the whole purpose to have it locked, so once it's made, it will be made on all iterations of it. However the main form linking to the subform is irrelevant as arnelgps code worked and does that I want.

The issue I have now, is using your code in linking two fields on two different subforms. As said in my step my step, it doesn't work.
So, the requirement will be to have a TextBox on the sub form. The textbox will show the text of the selected item from the combo box on the main form and the textbox will be locked or disabled. Correct?
 

TPS

Banned
Local time
Today, 06:37
Joined
Oct 1, 2019
Messages
64
So, the requirement will be to have a TextBox on the sub form. The textbox will show the text of the selected item from the combo box on the main form and the textbox will be locked or disabled. Correct?

I think you have missed my previous replies. No, the main form doesn't interact with what I am trying to do now.

The requirement is to link a selection on a subform, so that it links on another subform, much like what I have already done with the help of arnelgp's code. See my reply again:

On Marketing Template Subform, in Design View, I created an Unbound Combobox called Unbound_BookDiscount.

I set the control source to be:

Code:
Forms![frm_Publisher_Info_Subform]![Book_Discount_Code]

Because when Book Discount Code on the Publisher Info Subform is changed, I want this Unbound control to be changed.

I then went to the Publisher Info Subform and clicked the combobox called Book Discount Code. I clicked on Event and then clicked on After Update and selected Event Procedure. I then clicked on the 3 dots and it opened VBA. I then have this code from Bob Fitz, modified to work in my application:

Code:
Private Sub Book_Discount_Code_AfterUpdate()
Me.frm_Marketing_Subform.Form.Unbound_BookDiscount.Requery
End Sub

Which as I understand it says, When Book Discount Code is updated, requery the combobox Unbound_Book Discount on the Marketing Subform.

Save.

Right click main form and click on Form View and test by changing Book Discount Code on Publisher Info Subform.

I then get the following error:

Code:
Compile Error:
Method or data member not found

VBA then automatically highlights the following:


Code:
.frm_Marketing_Subform

Which from what I understand, is saying the subform name is wrong or not found but it isn't as I copied and pasted this from working code in arnelgp's solution. Arnelgp's solution works fine if I am referencing the main form to a subform.

So what am I doing wrong? Is this now clearer what I am doing and what code I am using, from which contributor and where it's going wrong?

I may just ask a mod to close this and start a new thread.
 
Last edited:

bob fitz

AWF VIP
Local time
Today, 06:37
Joined
May 23, 2011
Messages
4,717
So, is this second subform,
Another subform on the main form
Or a subform on the first subform
 

TPS

Banned
Local time
Today, 06:37
Joined
Oct 1, 2019
Messages
64
So, is this second subform,
Another subform on the main form
Or a subform on the first subform

As previously said, what I am trying to do now, is take a field from one subform, make a selection within that field and then have another field on another subform update based on the first selection.

My step by step in the previously reply explains this and shows this.
 

bob fitz

AWF VIP
Local time
Today, 06:37
Joined
May 23, 2011
Messages
4,717
As previously said, what I am trying to do now, is take a field from one subform, make a selection within that field and then have another field on another subform update based on the first selection.
And how that is done will depend on where the second subform is.
 

bob fitz

AWF VIP
Local time
Today, 06:37
Joined
May 23, 2011
Messages
4,717
Which I've answered before, all of the subforms are kept on the main form.

What is the post number in which you said that the second subform was on the main form
 

isladogs

MVP / VIP
Local time
Today, 06:37
Joined
Jan 14, 2017
Messages
18,186
@TPS
I have restored this thread that you deleted as it has multiple replies by Bob Fitz and others.
Even if no longer useful to you, it may be to others.
Thanks for understanding.
 
Status
Not open for further replies.

Users who are viewing this thread

Top Bottom