[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Access 2007 VBA issue

Posted on 2009-02-13
8
Medium Priority
?
299 Views
Last Modified: 2012-05-06
I have converted an application from Access 2003 to Access 2007. I had to disable some code to make the form load. However there are still some functionalists that don't seem to work and as a result Access crashes - Any ideas?

Access crashes as soon as it reaches the following line..

 Me.cboTaskCreatedBy = Val(Me.lblUserID.Caption)
Me.txtTaskCreateDate = Now
 Me.cboTaskCreatedBy = Val(Me.lblUserID.Caption)

Open in new window

Crash-shot.png
0
Comment
Question by:mkarkoukli
  • 4
  • 3
8 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 1200 total points
ID: 23638123
What is the contents of

Me.lblUserID.Caption ?

Hey ... at least they are sorry for the inconvenience!

mx
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 1200 total points
ID: 23638138
Instead of 'converting', how about taking your original A2003 app .... >> create a brand new empty A2007 ACCDB, then import ALL objects into the ACCDB from the A2003 app.

And before you do this, run this procedure on the A2003 app - for good measure:

if you have not already:
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.

"C:\Program Files\Microsoft Office\Office\Msaccess.exe" /decompile "C:\Access2003Clients\YourMdbNameHERE.mdb"

For more detail on the Decompile subject ... visit the Master on the subject (and other great stuff) Michael Kaplan:

http://www.trigeminal.com/usenet/usenet004.asp?1033

mx
0
 

Author Comment

by:mkarkoukli
ID: 23638150
The content is an integer to bind it to the combo box..

Microsoft let their users to be the testing filed for their products. lol
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 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 1200 total points
ID: 23638168
"The content is an integer to bind it to the combo box..'

Can you give an example?  Why are you using Val() ?

mx
0
 

Author Comment

by:mkarkoukli
ID: 23638194
I'm using the Val() in order to convert the value from a label control to a numeric. As far as I know the caption will hold a string, but the combo box requires a numeric value (which is the key field) to show the name.
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 1200 total points
ID: 23638226
If the Caption is all numbers then (?) ... try this workaround:

CLng(Me.lblUserID.Caption)

BUT ... try the import and decompile procedure also.

mx
0
 

Author Comment

by:mkarkoukli
ID: 23638296

No, that didn't work either. I even tried without any conversion, the same error happened.
0
 
LVL 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 300 total points
ID: 23640484
See if you have a stray .ldb file in the same folder as the database. Do this with the db closed; there should be NO .ldb files in that folder with the same name as your database. For example, if your db is named MyDatabase.mdb, Access will create a lockfile named MyDatabase.ldb ... sometimes this file isn't destroyed when Access ends abruptly, and can cause issues if not removed.

Still, as MX said, if you must work with a 2003 or earlier db in 2007, you should always create a new, blank db in 2007 (you can do so in the earlier formats - no need to convert to the .accdb format if you don't want) and import everything into it.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

830 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