• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 386
  • Last Modified:

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

  • 5
  • 5
1 Solution
Me.Recordset.FindFirst "[Client Membership ID] = " & Me.OpenArgs
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:
so if the form had the name:
~!@#$%^&*()_+= -{}:;"'<,>?/|~
Referencing the textbox would be:
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).

dpokerbearAuthor Commented:
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?
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

It could be a corrupted database or form.  Going past step 7 will probably not help for this problem. I include the additional steps for your future reference.

Steps (approximately in order) to use to fix a corrupted Access database. (Test after each step.)


2) Compact and repair

3) Use jetcomp.exe  http://support.microsoft.com/default.aspx?scid=kb;en-us;Q273956

4) decompile: in run: msaccess "dbPathName.mdb" /decompile
   Compact/repair:  in run: msaccess "dbPathName.mdb" /compact
   compile: in VB editor: debug> compile

5) Use a backup (you have a lot of those -- yes?)

6) If you can identify one or a few forms or reports causing problems, copy the problem form/report from a backup.  Or create a new form/report and copy all the objects in the old form/report to the new one. Copy the code from the old form/report using the undocumented
    Application.SaveAsText acForm, FormName, "C:\" & FormName & ".txt"
then paste that from Notepad into the new form/report.  If a module, copy the code using SaveAsText, create a new module, paste the code into the new module.

7) Create a new database, use File> Get external data> Import to get all objects of the damaged database and set up the options again.

8) Try a recovery tool:

9) Hire a company to repair the database  http://www.pksolutions.com/services.htm

Additional information:
How to Troubleshoot/Repair Damaged Jet 3.0 and Prior Databases

How to Troubleshoot Corruption in a Microsoft Access Database

Corrupt Microsoft Access MDBs FAQ
dpokerbearAuthor Commented:
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.
dpokerbearAuthor Commented:
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.
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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).
dpokerbearAuthor Commented:
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.
dpokerbearAuthor Commented:
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!


Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now