[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Requery Based on a Checkbox

Posted on 2006-06-29
20
Medium Priority
?
403 Views
Last Modified: 2012-05-05
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.
0
Comment
Question by:BigCat53
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
20 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 17008801
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
 
LVL 65

Expert Comment

by:rockiroads
ID: 17008863
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
 
LVL 26

Expert Comment

by:dannywareham
ID: 17009120
That was gonig to be my link   :-)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 65

Expert Comment

by:rockiroads
ID: 17009186
So Sorry. I'll try to be slower next time :)
0
 

Author Comment

by:BigCat53
ID: 17009298
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
 

Author Comment

by:BigCat53
ID: 17009380
I get the error message after putting in the form name for the subform 2.  
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17009385
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
 

Author Comment

by:BigCat53
ID: 17009549
I do have the proper subform name
0
 

Author Comment

by:BigCat53
ID: 17009591
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
 
LVL 65

Expert Comment

by:rockiroads
ID: 17009620
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
 
LVL 65

Expert Comment

by:rockiroads
ID: 17009750
if subform2 is a subform of subform1
u can do this

Me.Engineered_System_PD.Form.Requery
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17009756
or look at the link provided and try the various methods there
0
 

Author Comment

by:BigCat53
ID: 17010498
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
 
LVL 4

Expert Comment

by:Carl2002
ID: 17010745
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
 
LVL 65

Expert Comment

by:rockiroads
ID: 17011259
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
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 17011411
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
 

Author Comment

by:BigCat53
ID: 17011849
with the new code I get the following error message:

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

any thoughts?
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 1200 total points
ID: 17015796
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
 

Author Comment

by:BigCat53
ID: 17017102
that did it.  thank you for your assistance.
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17017741
no probs
The other way should work as well, not to worry
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question