Requery Based on a Checkbox

I have a form that contains two subforms.  What I am trying to do is have a user select accounts on subform 1 that are delinquent and after they click the box for that record to indicate Yes, I would like the other subform, subform 2,  to populate with that account so they can enter the reason it is delinquent.  I know I have to use VBA Requery but I can not get it to work.  The only way that subform2 populates is if I close and reopen.  Could someone advise how to do this?  Thank you in advance.
BigCat53Asked:
Who is Participating?
 
rockiroadsConnect With a Mentor Commented:
ok, lets try specifying the full form object

u con confirm this with the link provided


Private Sub Past_Due_AfterUpdate()
    If Past_Due.Value = True Then Forms!Mainform!Subform2.Form.Requery
End Sub

substitute MainForm with the name of your mainform
Subform2 with the name of the form u want to requery

now the names u put here are actual names of the form, not the name given the the control on the form

If there are spaces, do what PDB says, wrap with square brackets

Private Sub Past_Due_AfterUpdate()
    If Past_Due.Value = True Then Forms!Mainform![Subform2].Form.Requery
End Sub
0
 
rockiroadsCommented:
u could try this on the AfterUpdate event of that chkbox in subform1

private sub chkBox_AfterUpdate

    if chkBox.Value = True then  Me.Parent.<<nameofsubform2>>.form.Requery

end sub

0
 
rockiroadsCommented:
some more info for u

I have always preferred using Me.Parent or Me.subform but thats just me.

The other way of course is to use forms!formname!... etc

here is a useful guide for you

http://www.mvps.org/access/forms/frm0031.htm

0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
dannywarehamCommented:
That was gonig to be my link   :-)
0
 
rockiroadsCommented:
So Sorry. I'll try to be slower next time :)
0
 
BigCat53Author Commented:
When I use:

private sub chkBox_AfterUpdate

    if chkBox.Value = True then  Me.Parent.<<nameofsubform2>>.form.Requery

end sub

I get the following error message:

Run-Time error '424'
Object Required
0
 
BigCat53Author Commented:
I get the error message after putting in the form name for the subform 2.  
0
 
rockiroadsCommented:
urm, did u change <<nameofsubform2>> to be the name of your subform?

it has to be the control name

if in your vba window for your main form
u typed in Me.
it brings up a list, u can then find the name given to your subform
or of couse look it up design mode
0
 
BigCat53Author Commented:
I do have the proper subform name
0
 
BigCat53Author Commented:
This is my code that I am using:

Private Sub Past_Due_AfterUpdate()
If chkBox.Value = True Then Me.Parent.Engineered_System_PD.Form.Requery
End Sub


Engineered_System_PD is the name of subform 2.  I have the code in the After Update event for the checkbox in Subform 1.
0
 
rockiroadsCommented:
How are your subforms presented

Are they both subforms from one form
or is subform2 a subform of another subform  (man after several beer's that sentence would do your head in!)
0
 
rockiroadsCommented:
if subform2 is a subform of subform1
u can do this

Me.Engineered_System_PD.Form.Requery
0
 
rockiroadsCommented:
or look at the link provided and try the various methods there
0
 
BigCat53Author Commented:
Nothing is working.

Main Form: Accounts Past Due
Subform1: System_Accounts_Past_Due
Subform2: Manager_Accounts_Past_Due

Subforms are both subforms of Main form, but they are based on different querys (not sure if this matters).  When the checkbox is clicked "yes" in subform1, I want That account to show up in Subform2.  I put the following code in the Afterupdate event for the checkbox:

If chkBox.Value = True Then Me.Parent.Manager_Accounts_Past_Due.Requery

But I continue to get this error message:  Run-Time error '424'     Object Required

I don't know where to go from here.  Obviously the code is wrong or the forms are linked wrong, but how do i know?  Thank you for future assistance.
0
 
Carl2002Commented:
Private Sub Past_Due_AfterUpdate()
If chkBox.Value = True Then Me.Parent.Engineered_System_PD.Form.Requery
End Sub

Do you need the extra dot after the word parent ?
0
 
rockiroadsCommented:
is chkBox the name of your checkbox field? I assume its Past_Due based on the AfterUpdate function?
If Past_Due is the checkbox, then do this


Private Sub Past_Due_AfterUpdate()
    If Past_Due.Value = True Then Me.Parent.Engineered_System_PD.Form.Requery
End Sub


Wotcha Carl!
0
 
puppydogbuddyCommented:
You a space after manager and before underscore:
               If chkBox.Value = True Then Me.Parent.Manager_Accounts_Past_Due.Requery
If space is intended, it requires brackets; oterwise eliminate.
0
 
BigCat53Author Commented:
with the new code I get the following error message:

Run-Time error '2465'
Application-defined or object-defined error

any thoughts?
0
 
BigCat53Author Commented:
that did it.  thank you for your assistance.
0
 
rockiroadsCommented:
no probs
The other way should work as well, not to worry
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.