Link to home
Start Free TrialLog in
Avatar of dpokerbear
dpokerbearFlag for Australia

asked on

OpenArgs causing a problem

In the code listed below, I am passing the arguments from one form to another and then using OpenArgs to find the appropriate record on a newly opened form.

The problem I am experiencing with this is when the form is opened, in the status bar it says "Calculating..." and it sits like that for about a minute. I can see the subform flickering while this is going on.

It finds the right record and all, but I can't figure out what is it trying to Calculate???????
Private Sub cmdPaymentTransactionsContainer_Click()
    
DoCmd.OpenForm "frmPaymentTransactionsContainer", acNormal, , , , acDialog, Me!     [frmMembershipClientTransactions].Form.[Client Membership ID]

End sub

--------------------------------

Private Sub Form_Load()
        'Read arguments passed from the previous form and find corresponding record
        Me.Form.Recordset.FindFirst "[Client Membership ID] = " & Me.OpenArgs
End Sub

Open in new window

Avatar of thenelson
thenelson

Try:
Me.Recordset.FindFirst "[Client Membership ID] = " & Me.OpenArgs
BTW:
It is best to avoid spaces, underscores and other special characters in your naming of objects. For example: CountOfPeopleLive is just as easy to read as Count Of People_Live.  Objects named with special characters including spaces need to be placed in brackets for access to recognize them correctly. Here is an extreme example of the problems you will have using special characters in your names:
I named a textbox
!@#$%^&*()_+= -{}:;"'<,>?/|~
And had access create an event procedure.  Access converted the name of the textbox to:
Ctl_____________________________
so if the form had the name:
~!@#$%^&*()_+= -{}:;"'<,>?/|~
Referencing the textbox would be:
Forms!L_____________________________!Ctl_____________________________
a useful tip for someone who doesn't want someone else (probably even themselves) from reading their code.
And spaces will sometimes cause problems in vba references even after years of trouble free operation.

It is also a good idea to use a naming scheme such as leszynski naming conventions (see references). It makes it clearer what type of object you are naming and it reduces the risk of duplicate name problems (like a control name and its control source).

References:
Http://Www.Xoc.Net/standards/rvbanc.Asp
http://Www.Dhdurso.Org/articles/ms-access-naming.Html
http://Www.Acc-technology.Com/namconv.Htm
http://Www.Databasedev.Co.Uk/naming_conv.Html
http://En.Wikipedia.Org/wiki/leszynski_naming_convention
Avatar of dpokerbear

ASKER

After doing some more testing, I found something even more disturbing than the problem I quoted initially.

I took everything out of form load and this is the only line I have in it.

MsgBox Nz(Me.OpenArgs, 0)

What happens is a problem with a form focus. The "Calculating..." message in the status bar stays on the form and the whole form is flashing until I start moving the mouse. Then it gets the focus and is fine.

If I take the OpenArgs line (mentioned above) out of the Load Form, then this problem doesn't happen.

It seems to be a form focus problem but only when OpenArgs is used in Form Load OR Open Form Sub.

Why is this happening?
ASKER CERTIFIED SOLUTION
Avatar of thenelson
thenelson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Nelson,

I found what the problem is. I didn't have to use any of the steps you recommended, thanks for your advice though anyway.

This, I think is a major Microsoft Bug in Access and unfortunately, it's nothing to do with the problem I posted originally.

If you have a form which calls another form and mouse cursor happens to be in an un-populated area of a datasheet, you'll get a message Calculating... in the status bar and you may notice some values are continuosly refresing as if something is thrashing away in the background. Some loose code or while loop or god knows what...

If you move the mouse out of the un-populated area of the datasheet, it stops.

Try it and see. Let me know if you can get it to happen.
Further to my comment earlier, this only happens on a datasheet with Conditional Formatting.
No, I don't get the problem (A 2003).  Try creating a new database and see if it happens there.
Neither do I, therefore it is most certainly not a bug. As Nelson said, you obviously have corruption in your form (or in your database).
Hi guys,

I created a dummy database and tested it. You are right, it doesn't happen all the time. I took the conditional formatting out of the form that was causing me the problem and that fixed the problem.

Therefore, it must have been something to do with conditional formatting. Later on, I'll try to put it in again, but for now I am happy to let this one rest.

Thanks again for your help. Will keep you posted if it happens again.

Nelson, I am happy to award you the points for that info on backup and repair. That is useful info. Thanks.
Thanks for the info.
| would at least try the decompile (step 4) to see if that fixes the problem.

You're welcome.  Glad to help and thank you very much for the points with "A" grade!

Happy computing!

Nelson