Solved

Help! - Me.Form quit working

Posted on 2011-03-04
15
347 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

752 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