Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The correct compile syntax for DoCmd.SetWarnings (WarningsOff) 1

Status
Not open for further replies.

vamoose

Programmer
Oct 16, 2005
320
MX
I am using the Option Explicit statement on my forms VBA code as the performance analyzer suggested. Now when I try to compile the VBA code it has a problem with this:
DoCmd.SetWarnings (WarningsOff)
Compile error saying that the "variable is not defined" Any ideas ?

Thanks
 
Can you post the code where you have declared the WarningsOff variable. My guess is that you have added the Option Explicit which requires you to declare your variables. You probably did not have this variable declared and thus it is now faily.

You can test this by removing the Option explicit and see if it returns to working.


Andy Baldwin

"Testing is the most overlooked programming language on the books!"

Ask a great question, get a great answer. Ask a vague question, get a vague answer.
Find out how to get great answers FAQ219-2884.
 
Yes it works fine without the Option Explicit statement. I somehow now need to declare this as a variable? This text comes up highlighted:

WarningsOff

with the error:

"Compile error: variable not defined"


 
Can you post your code please?


Andy Baldwin

"Testing is the most overlooked programming language on the books!"

Ask a great question, get a great answer. Ask a vague question, get a vague answer.
Find out how to get great answers FAQ219-2884.
 
[Form_frm_reports(Code)]

Option Explicit
Option Compare Database

Private Sub Form_Close()

DoCmd.SetWarnings (WarningsOff)
DoCmd.RunSQL "delete * from tbl_filename"

End Sub

 
As rj says docmd.setwarnings false

In your code you may be manipulating a WarningsOff variable somewhere else

In that case you would need to add

dim WarningsOff as boolean

WarningsOff = False or true depending on what you want.

Then your original code will work.


Andy Baldwin

"Testing is the most overlooked programming language on the books!"

Ask a great question, get a great answer. Ask a vague question, get a vague answer.
Find out how to get great answers FAQ219-2884.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top