Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Help! - Me.Form quit working

Posted on 2011-03-04
15
Medium Priority
?
351 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

721 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