473,396 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

I have a report that is query driven, when I run it, the macros stop working?

Rebecca Ross
I have built an Access DB, it uses a form to enter the data into the db. The form also has a macro for three dif types of documents/receipts to print depending on the data entered. All functions nicely, until we run a new report that I developed. The report is driven by a query, if I run this report, the macros stop functioning and I get the following error message:

Microsoft Visual Basic for Applications:
Compile Error:
Expected: Identifier

Any ideas?

Thanks so much...
Oct 22 '12 #1
7 1848
zmbd
5,501 Expert Mod 4TB
Basically, VBA is trying to tell you that one of the lines in the code has a variable not set as expected usually a function.

Are you writing in VBA or using the Macros... these are related but VERY different. MS made the mistake of refering to VBA as Macros in Excel and that creates some confusion.

Hopefully you're using VBA as you can open the VBA-Editor (<ALT-F11>) close all the open program windows... under the debug option in the ribbon select compile... this should then choke on the line in the code that is giving the error. From there post back the code, format it with the <CODE/> button, and indicate which line in the code caused the error.

Macros are a tad harder to troubleshoot and We'll need to know what version of MS Access you're using (infact, that information is always helpful)
Oct 22 '12 #2
Thank you... I am using Access 2010

It's odd, the report is driven by this query below, but the Macros that stop functioning are NOT. If I do NOT run the report, I do not have an issue. It's almost like something/setting within the report takes control of the Macros after it runs... I hope that I explained the problem clearly enough... ;)

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub Criminal_Complaint_Click(Is Not Null)
  4.  
  5. If Criminal_Complaint_Click = True
  6.  
  7. Or
  8.  
  9. If MDJ_Fingerprinting_Order_Click = True
  10.  
  11. Or
  12.  
  13. If Warrant_Service_Click = True
  14.  
  15.  
  16. End Sub
----It stopped at the (Is Not Null), does that mean that I should remove that line of code?
Oct 22 '12 #3
zmbd
5,501 Expert Mod 4TB
Sorry... this is going to be a Dentist visit:

First:
<alt-f11> to open the VBA editor.
menubar/tools/options
{editor} tab
- Uncheck "Auto Syntax Check" - your lines will still turn red however, you will nolonger receive the message prompt that you've goofed... I find it annoying to have to clear that box and then reselect the line to fix something I've mis-typed.
- Check "Require Variable Declaration" - this will now Force you to declare all of your variables before using them - Trust me, once you get the hang of it, you will apprecite the troubleshooting tool. It is sooooo easy to mistype a variable and then not be able to finde it when you're expecting one thing and your eyes fool you into thinking things are one way and not the other.

Now for the pain...
One by one... seriously just one at a time
Open all of your modules, class modules (if you don't know about these then you don't have them), form modules, reports...

Right below Option Compare Database insert the following: Option Explicit

Save everything.

Close all of the code windows again.
Go back to the Access interface (leave the VBA editor open)
and close all of the forms and reports that are open.

Go back to the VBA editor:
menubar/debug/compile
(the compile might be followed by "db1" or someother thing... however, the menu option should be first).
Lets see where the compiler chokes

:)
Oct 22 '12 #4
zmbd
5,501 Expert Mod 4TB
Sorry,
Got called into the lab and someone pressed enter on the keypad (or that's my story) - maybe it was the screen saver. Been weird things happening on my work pc for the past few weeks.

Yes remove the Is Not Null from the Criminal_Complaint_Click... please do the reset of my post and then compile.

Also the remainder of your code is troublsome... on_click events are not usually boolean. Very weird. Subs do not return values so testing them for true/false is not done.

We'll need to see the rest of your code once you get thru clearing the errors that the compiler is going to bury you in.

Also
It's odd, the report is driven by this query below, but the Macros that stop functioning are
what you posted is not called a query... I'm not even sure if it passes for VBA-code but that is what it is trying to be....
A query is something like:
Expand|Select|Wrap|Line Numbers
  1. SELECT field1,
  2.    field2,
  3.    field3
  4. FROM tbl_sometable
  5. WHERE ((field1='somestring')
  6.    AND (field2=#somedate#)
  7.    AND (field3 = 0));
Oct 22 '12 #5
Thanks so much! I followed your advice, Unchecked "Auto Syntax Check" and then made sure that I Checked "Require Variable Declaration" - I then removed that line of code "Is Not Null" and all works great now! Sometimes it's the simplest things that wreak such havoc! As I read the code, that command line didn't make sense...I should have saw that sooner!
Oct 22 '12 #6
zmbd
5,501 Expert Mod 4TB
YEa.... I think!?
Well... you know where to come back to should it start acting up again... glad I could help - not exactly sure what I did though.
Best of Luck
Oct 22 '12 #7
NeoPa
32,556 Expert Mod 16PB
That surprises me Rebecca. If your code is exactly as you have it displayed except for the "is not null" being removed then I still don't see how it can compile as it doesn't appear to be in the right format at all for VBA code.

I guess if everything is working now then you have less of an issue, but if you haven't set Option Explicit in every module and compiled the project then I can see you (or your project more likely) suffering badly from unexpected problems.

VBA can take code of many shapes and sizes but an "Or" alone on a line should always throw up a compilation error.
Oct 23 '12 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Mike | last post by:
I have to pass a date from a form to a report query. I have written a query that works fine when I execute from SQL view, But I dont know how to pass a value from the form to this query. SELECT...
2
by: Adlai Stevenson | last post by:
Ok, the good news is the last kernel upgrade made bzflag stop working. The bad news is that mplayer, ogle and real player stopped working ! Is anybody in a similar boat? I am using Suse 9.1...
0
by: Adrian Stovold | last post by:
I've written an ASP.NET application in VB.NET. It works fine on all Windows platforms and browsers, but there's a problem on the Mac version of IE (v5.1.5) running on Mac OS 9.2. I can reproduce...
7
by: z f | last post by:
Hi, i have a vb.net web application that uses validators. on my dev machine (Xp pro) it works fine. on the hosting machine (win2003) the validator (client side and server side ) stop working....
1
by: z.ghulam | last post by:
I am designing an order database at work and am having problems creating a specific report I'm after. Basically, each order has an 'order type' and what I would like is a report which lists the...
14
by: ineedahelp | last post by:
I have included a snip of my code. I am trying to output my results to a report or a query. Right now I can see my results in the immediate window due to my DEBUG command. how can I take these...
2
by: mudman04 | last post by:
Hi, I searched online for some similar issues that I am facing but was not able come up with anything. I am fairly new with Access (2 months experience) and I am trying to remove a message...
5
by: alive84 | last post by:
Hi folks, I need once again your help. I have a long SQL-Report Query, which has an error build in, however, I do not see it at all. I have typed it with the SQL-Builder, not with the Wizard...
11
tuxalot
by: tuxalot | last post by:
The easy way is to put cancel = True in the On No Data event of the report. But why replicate code across all reports that way? My app selects reports from a listbox, so I would prefer to check the...
1
by: ncsthbell | last post by:
I created a form "frmReportParms", on this form I have created a combo box box which lists 'divisions'. I put code behind the 'after click' event on the combo box to move the value selected to a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.