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

x
?
Solved

On Current No to working properly

Posted on 2014-04-28
7
Medium Priority
?
242 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
[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
  • 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 27

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 27

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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.
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 …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

670 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