Solved

Help! - Me.Form quit working

Posted on 2011-03-04
15
343 Views
Last Modified: 2012-05-11
I made a minor change in the vba on a form, now Me.Form. is generating errors (different error depending on which module is in use).  When I attempt to compile the database it errors out with "method or member not found"

I'm at a total loss.
0
Comment
Question by:cmccurdy
  • 5
  • 5
  • 2
  • +2
15 Comments
 
LVL 75
ID: 35040607
You will need to up load ... or at least show exactly where this code is being used?

Normally, you would not use Me.Form  .... because ME is already referencing the Form (or Report) you are currently in.  And ... you cannot use Me in an regular VBA module.

mx
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35040621
what did you replace with "Me.Form"

"Me.Form" is not complete by itself, you need more code to follow
0
 
LVL 84
ID: 35040626
What's the purpose of "Me.Form"? What does it do? In most cases it's not needed ...

You might try a Decompile:

Build a shortcut with this as the targert:

"full path to msaccess.exe" "full path to your database" /decompile

0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:cmccurdy
ID: 35040759
This is happening in several forms and the code has worked fine for a couple of years.  The changes I made today were small and not in this form but this is the result.

The specific line is Me.Form.Requery - Me.Requery gives the same result.

I try decompiling to see if it helps.
0
 
LVL 75
ID: 35040774
Make a *backup* before you Decompile !
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35040786
also check Tools >references
see if you have reference prefixed with "MISSING: "
0
 

Author Comment

by:cmccurdy
ID: 35040873
Decompiling did not change the compile errors.

But to complicate things further it works in most modules but gives errors when i compile manualy.  However is is failing on execution in a module where I am intercepting the new record before it's written and using an existing record instead.  The purpose is to keep the database from bloating so much since these are temporary records which are cleared later.  The code for the bombing module is below.


Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim rs As Recordset, strControlName As String, ThisRecord As Integer
    If Me.NewRecord Then
        strControlName = Me.ActiveControl.Name
        ThisRecord = UseExistingRecord
        Me.ActiveControl.Undo
        Me.Form.Requery
        Set rs = Me.Form.RecordsetClone
        rs.FindFirst "InvoiceAddID = " & ThisRecord
        If Not rs.EOF Then Me.Bookmark = rs.Bookmark
        Forms("frm_InvoiceAdd").Controls(strControlName).SetFocus
    End If
End Sub
0
 

Author Comment

by:cmccurdy
ID: 35040876
No missing references.
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
ID: 35040906
"compile errors."
Are these the error you are talking about ? Or are the compile errors in addition to the other errors. If so, all bets are off until you fix the Compile errors.

Also ... I'm noting - not particularly related ... that you are doing a Requery in the Form BU event. Not a good idea nor the place to be doing a requery.

mx
0
 
LVL 75
ID: 35040911
Can you upload a sanitized version of the db ... an how exactly to replicate the issue ?

mx
0
 

Author Comment

by:cmccurdy
ID: 35040985
Ok, breathing roomm..  The backup reminder reminded me I had backups.   Since I'd made no changes to that module, I deleted it and pulled it back from an old version.  It now runs fine, but when I try to compile manually I'm still getting the  "property or method not found" where I'm using Me.Form.X (Requery, refresh, etc.)

I don't understand this so I'll start comparing the current version (which now runs without and error but won't compile) thiss weekend.

Santiizing would require more time than I have right now, but if I don't find a solutiion to the compiling errors I will not that also.
0
 
LVL 75
ID: 35041003
ok ... good luck.
Noting again ... that you don't need

Me.Form.Requery ..

only

Me.Requery ...

mx
0
 
LVL 84
ID: 35043146
<you are doing a Requery in the Form BU event. Not a good idea nor the place to be doing a requery>

Absolutely, completely agree. There is no reason to Requery during the BU event, and in fact I'm surprised this works.

<the code has worked fine for a couple of years. >

Access has always been somewhat forgiving in regard to code syntax, and in fact many times it comes down to a matter of personal prefence - for example, Me.txtYourTextbox vs Me.Controls("txtYourTextbox") vs Me!txtYourTextbox. Variations of that nature are fine.

HOWEVER

When your code beings to error out, and when you've been advised by 3 Access MVPs that your code syntax is non-standard, it might be time to consider refactoring. In most cases this can be attributed to nothing more than a glitch, but anytime I see out-of-the-blue errors like this I get nervous. Also, as you move forward with Access into 2007 and 2010, you'll find those environments far less forgiving that 2003.
0
 
LVL 21
ID: 35047863
cmccurdy,


Since you are only wanting your code to run for a new record then I would also recommend that you use the Before Insert event. This event only fires for a new record.

Curious,  why do you need Me.Requery? Are you looking for new records added since the last requery?
0
 

Author Comment

by:cmccurdy
ID: 35098112
I ran out of time to investigate but was able to pull working forms from my backups so it's all working for now.  On the subject of the Requery in the requery event I'm using it to intercept data entered and move it to an existing record before the new record is created.  However I will take the advice of the experts and fiind a different way to accomplish this.  Thanks to all the experts for your input.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

813 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now