Solved

On Current No to working properly

Posted on 2014-04-28
7
231 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

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
"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
Comment Utility
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

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
"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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 26

Expert Comment

by:MacroShadow
Comment Utility
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
Comment Utility
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 26

Expert Comment

by:MacroShadow
Comment Utility
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 - Access MVP) earned 500 total points
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
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…
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…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now