Solved

access vba on error

Posted on 2013-01-31
2
243 Views
Last Modified: 2013-02-06
I have this
I need it to do nothing if the isloaded fails at present it gives an error message and I dont want that.

 If Forms!frmexportvincode.Form.Controls.Item("BtnToggleSyncForms").Value And CurrentProject.AllForms("FrmSMMTMaster").IsLoaded = True Then
 
 
                        Forms!frmexportvincode.Form.Controls.Item("TxtExportMvrisFromSMMT").Value = Me.MVRIS_CODE.Value

                    End If

Open in new window

0
Comment
Question by:PeterBaileyUk
2 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 250 total points
ID: 38843062
I don't see how you can be getting an error from this bit of code.
If isloaded is false it already does nothing.

Is there more code that follows this?
If so, and you want to prevent that code from running then you can do

If Forms!frmexportvincode.Form.Controls.Item("BtnToggleSyncForms").Value And CurrentProject.AllForms("FrmSMMTMaster").IsLoaded = True Then
 
     Forms!frmexportvincode.Form.Controls.Item("TxtExportMvrisFromSMMT").Value = Me.MVRIS_CODE.Value
else
     exit sub  '(or exit function, whatever this code is in)
End If

Note that this will also cause an exit if FrmSMMTMaster IS loaded but BtnToggleSyncForms is false.
0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 250 total points
ID: 38857408
Yes, issue like this are sometimes more or less meaningless without any context...

But first try Pete's suggestions, then post a sample database :

Sample database notes:
1. Back up your database(s).
2. Combine the front and back ends into one database file.
3. Remove any startup options, unless they are relevant to the issue.
4. Remove any records unless they are relevant to the issue.
5. Delete any objects that do not relate directly to the issue.
6. Remove any references to any "linked" files (files outside of the database, Images, OLE Files, ...etc)
7. Remove any references to any third party Active-x Controls (unless they are relevant to the issue)
8. Remove, obfuscate, encrypt, or otherwise disguise, any sensitive data.
9. Unhide any hidden database objects
10. Compile the code. (From the VBA code window, click: Debug-->Compile)
11. Run the compact/Repair utility.
12. Remove any Passwords and/or security.
13. If a form is involved in the issue, set the Modal and Popup properties to: No
    (Again, unless these properties are associated with the issue)
14. Post the explicit steps to replicate the issue.
15. Test the database before posting.

In other words, ...post a database that we can easily open and immediately see and/or troubleshoot the issue.
And if applicable, also include a clear graphical representation of the *Exact* results you are expecting, based on the sample data.

JeffCoachman
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
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…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

705 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

20 Experts available now in Live!

Get 1:1 Help Now