Solved

Help! - Me.Form quit working

Posted on 2011-03-04
15
344 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 - Microsoft MVP, Access and Data Platform) 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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.

821 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