Solved

Help! - Me.Form quit working

Posted on 2011-03-04
15
348 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 85
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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

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 85
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

617 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