Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

On Current No to working properly

Posted on 2014-04-28
7
Medium Priority
?
244 Views
Last Modified: 2014-05-10
For some reason, my "On Current" event isn't working properly. When I open the database for the first time, and then I open the Form, a warning pops up saying there is something wrong with the "On Current" event. Then if I go into the event and simply click on it (change nothing) and save changes, it works perfect. It will continue to work perfect until I close the database and open it up again. At which time the same event happens.

The code is:

Private Sub Form_Current()
 Call cmOffice_AfterUpdate
End Sub

Open in new window


The AfterUpdate of cmOffice is:

Private Sub cmOffice_AfterUpdate()

Select Case Me!cmOffice
     Case "949 S. Orange County"
      Me.Detail.BackColor = 35584
    Case "714 N. Orange County"
     Me.Detail.BackColor = 65280
    Case "909 Riverside"
     Me.Detail.BackColor = 9141100
    Case "858 San Diego"
     Me.Detail.BackColor = 16436871
    Case "818 Los Angeles"
     Me.Detail.BackColor = 16741960
    Case "650 Silicon Valley"
     Me.Detail.BackColor = 52685
    Case "408 San Jose"
     Me.Detail.BackColor = 65535
    Case "925 Walnut Creek"
     Me.Detail.BackColor = 12695295
    Case "916 Sacramento"
     Me.Detail.BackColor = 7877325
     Case Else
      Me.Detail.BackColor = vbWhite
End Select

End Sub

Open in new window

0
Comment
Question by:cansevin
  • 3
  • 2
  • 2
7 Comments
 
LVL 75
ID: 40028005
"a warning pops up saying there is something wrong with the "On Current" event."
What is the error message ?

Also, have you tried a Decompile and Compact & Repair ?

mx
0
 

Author Comment

by:cansevin
ID: 40028022
Warning is attached. Yes, I did do the Compact and Repair. Not sure what the Decompile is, think that would help?
Screen-Shot-of-Warning.pdf
0
 
LVL 75
ID: 40028041
"think that would help?"
Not sure yet.
What kind of object is 'cmOffice' ?  A combo box ?

And is it on the same Form ?

I've seen this 'gosub' error a few times. and it never seems to make sense.

mx
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 28

Expert Comment

by:MacroShadow
ID: 40028046
1. Uncheck the boxes under:
Tools | Options | General | Name AutoCorrect
In Access 2007, it's:
Office Button | Access Options | Current Database | Name AutoCorrect
Explanation of why:
http://allenbrowne.com/bug-03.html

2. Compact the database to get rid of this junk:
Tools | Database Utilities | Compact/Repair
or in Access 2007:
Office Button | Manage | Compact/Repair

3. Close Access. Make a backup copy of the file. Decompile the database by
entering something like this at the command prompt while Access is not
running. It is all one line, and include the quotes:

4. Open Access (holding down the Shift key if you have any startup code),
and compact again.

5. Open a code window.
Choose References from the Tools menu.
Uncheck any references you do not need.
For a list of the ones you typically need in your version of Access, see:
http://allenbrowne.com/ser-38.html

6. Still in the code window, choose Compile from the Debug menu.
Fix any errors, and repeat until it compiles okay.

7. Still in the code window, choose Options on the Tools menu. On the
General tab, make sure Error Trapping is set to:
Break on Unhandled Errors
and the Compile on Demand is unchecked.

At this point, you should have a database where the name-autocorrect errors
are gone, the indexes are repaired, inconsistencies between the text- and
compiled-versions of the code are fixed, reference ambiguities are resolved,
the code syntax is compilable, and the VBA options are set to show errors
and avoid this kind of corruption.
0
 

Author Comment

by:cansevin
ID: 40028047
Yes... cmOffice is a combo box.

Yes, it is on the same form.

It seems to be only specific to my computer. When I tried it on another computer... with the same front end file. It didn't appear.

Thanks for your help!
0
 
LVL 28

Expert Comment

by:MacroShadow
ID: 40028053
I've seen this 'gosub' error a few times. and it never seems to make sense.
Microbug error messages rarely do make sense :-(
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 total points
ID: 40028107
OK ... you system only. Let's try the Decompile procedure:


Open the VBA Editor and from the menu ...Tools>>References ....
If you see any listed as **Missing: <reference name>, including the asterisks and the word Missing, the
you need to fix that first.

Then, follow this procedure:

****
0) **Backup your MDB BEFORE running this procedure**
****
1) Compact and Repair the MDB, as follows:
Hold down the Shift key and open the MDB, then from the menu >>Tools>>Database Utilities>>Compact and Repair ...
Close the mdb after the Compact & Repair.
2) Execute the Decompile (See example syntax below) >> after which, your database will reopen.
3) Close the mdb
4) Open the mdb and do a Compact and Repair (#1 above).
5) Close the mdb.
6) Open the mdb:
    a) Right click over a 'blank' area of the database window (container) and select Visual Basic Editor. A new window will open with the title 'Microsoft Visual Basic' ... followed by then name of your MDB.
    b) From the VBA Editor Menu at the top of the window:
       >>Debug>>Compile
        Note ... after the word Compile ...you will see the name of your 'Project' - just an fyi.

7) Close the mdb
8) Compact and Repair one more time.

*** Executing the DeCompile **EXAMPLE**:
Here is an **example** of the command line syntax  (be SURE to adjust your path and file name accordingly) before executing the decompile:

Run this from Start>>Run, enter the following command line - **all on one line** - it may appear like two lines here in the post:
Also, the double quotes are required
.
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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 …

885 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