Google Answers Logo
View Question
 
Q: Access 2002 - VBA Code - Referencing an AccessObject ( Answered 4 out of 5 stars,   0 Comments )
Question  
Subject: Access 2002 - VBA Code - Referencing an AccessObject
Category: Computers > Programming
Asked by: bselltiz-ga
List Price: $10.00
Posted: 31 Oct 2002 10:16 PST
Expires: 30 Nov 2002 10:16 PST
Question ID: 94352
I am developing an access 2002 application.
I have the following piece of code:

    Dim objCurProj As CurrentProject
    Dim objAcObj As AccessObject
    
    Set objCurProj = Application.CurrentProject
    
    For Each objAcObj In objCurProj.AllForms
        If objAcObj.IsLoaded = True Then
            Debug.Print objAcObj.NAME & " OPEN"
            objAcObj.Requery 'PROBLEM HERE
        End If
    Next

I am trying to call the requery method for any open form. The problem
is that I do not know how to reference the method based upon the value
I receive from the all forms collection.

Can you tell me how to accomplish this and let me know the logic
behind it?

Brian Selltiz
Digital Provisions
Answer  
Subject: Re: Access 2002 - VBA Code - Referencing an AccessObject
Answered By: hammer-ga on 31 Oct 2002 10:42 PST
Rated:4 out of 5 stars
 
Forms(objAcObj.Name).Requery 

The Forms collection has all the currently open forms.  It can be
indexed by name to get a particular Form. You can then use any methods
or properties of the Form.
Once IsLoaded returns True, then you know that the Form is available
in the Forms collection.

Please ask for clarification if you need further details. Good luck
with your database!

Request for Answer Clarification by bselltiz-ga on 31 Oct 2002 12:03 PST
Hey,
I need clarification on the correct syntax.
I tried the following code with no success:

    For Each objAcObj In objCurProj.AllForms
        If objAcObj.IsLoaded = True Then
            Debug.Print objAcObj.NAME & " OPEN"
            strName = objAcObj.NAME
            objCurProj.AllForms(strName).Requery
            objCurProj.AllForms(objAcObj).Requery 'doesn't work either
            objAcObj.Requery
        End If
    Next

Thanks for your help.

Brian

Request for Answer Clarification by bselltiz-ga on 31 Oct 2002 12:05 PST
geez, I'm a dope.
I missed the first line of your answer, sorry.
It works fine, thanks :->

Clarification of Answer by hammer-ga on 31 Oct 2002 12:19 PST
The first line is kind of lost agaianst the answer header. I'll have
to remember to put a blank line at the top of my answers!

Clarification of Answer by hammer-ga on 01 Nov 2002 04:43 PST
I see that you rated my answer at four stars. While you cannot alter
your rating, if there is some additional piece of information that you
need to make this a five star answer, please post a request for
clarification and I will be happy to attempt to provide it.

hammer-ga
bselltiz-ga rated this answer:4 out of 5 stars

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy