Solved

access vba on error

Posted on 2013-01-31
2
253 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

816 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

9 Experts available now in Live!

Get 1:1 Help Now