473,385 Members | 1,555 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,385 software developers and data experts.

code after "Docmd.OutputTo.." ignored?

54
Hi, I have used the Docmd.outputto function in various places in my code but for some reason all code that comes afterwards, even msgbox doesn't show. I was just wondering if there is anything that could be causing this. For example in the snippet below the docmd command brings up a box saying that it is outputting the file to c:\FullTimetable.snp but no msgbox appears saying "test". I have about 6 or so if statements with the same problem and i'm hoping it is nothing major. Your help is greatly appreciated!

Expand|Select|Wrap|Line Numbers
  1. If [Forms]![ReportsMenu]![InvigTTBySchool].Value = True Then
  2. ChoiceOne = True
  3. MyChoiceOne = "FullTimetablebyFaculty"
  4. MyReportOne = "FullTimetable"
  5.     DoCmd.OutputTo acReport, MyChoiceOne, "SnapshotFormat(*.snp)", "c:\" & MyReportOne & ".snp", False, ""
  6. MsgBox "test"
  7. Else
Thanks!

Allen
Dec 23 '09 #1

✓ answered by missinglinq

As NeoPa has pointed out, your code is causing an error, which drops you to the error handler, thus bypassing the message box. The problem is here:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acReport, MyChoiceOne, "SnapshotFormat(*.snp)", "c:\" & MyReportOne & ".snp", False, ""
Instead of acReport it should be acOutputReport, which should be popping up as a choice from Intellisense.

Linq ;0)>

16 4450
ChipR
1,287 Expert 1GB
Do any of your functions have error handling code?
Dec 23 '09 #2
g diddy
54
at the top of the function I have:

Expand|Select|Wrap|Line Numbers
  1. Function ExSnap1()
  2. On Error GoTo Macro1_Err
  3.  
and at the bottom I have:

Expand|Select|Wrap|Line Numbers
  1. Macro1_Err:
  2.     MsgBox Error$
  3.     Resume Macro1_Exit
  4. End Function
  5.  
apart from that there is no other error handling. PS Thanks for your quick response!!
Dec 23 '09 #3
ChipR
1,287 Expert 1GB
Very strange. Is the output file actually created? Does this happen with multiple reports? And, what happens if you stop on the DoCmd.OutputTo in debug and step forward?
Dec 23 '09 #4
Megalog
378 Expert 256MB
I've had this happen before. I think the problem was the report I was trying to output didnt have any records, so it would just drop the whole subroutine right at the DoCmd.OutputTo line.

Edit: Nevermind, I just tried recreating that scenario and the report outputs either way. If I remember exactly what the answer was I'll drop an update.
Dec 23 '09 #5
g diddy
54
that's another thing ChipR; it says the file has been created but it does not show up in the C drive. Also sometimes I get an error message saying that there is not enough free disk space to save it. I think this may be related in some way! However I cannot see why it isn't working - it used to work and the code for outputting it to a file is exactly the same. I'd hate to do it as the code is very long, but would pasting the entire code here be able to give you more context? I thought about that Megalog and i've just opened one of the reports and the information was there. However I do agree, I think that it may be just dropping the whole subroutine as after that line as even Msgbox "Test" doesn't work!!
Dec 23 '09 #6
g diddy
54
just done the step into and it went straight from the DoCmd Output To... to the error handler. No explanation why though!!
Dec 23 '09 #7
Megalog
378 Expert 256MB
I've seen the out of memory error happen when you try to feed an illegal filename/filepath into the command line. Although the filename you're using is about as simple as it can get. Are you on a work machine where perhaps your local policy is preventing files from writing to the root of your C: drive? Try hardcoding the output filepath/filename to your desktop location.
Dec 23 '09 #8
Megalog
378 Expert 256MB
This can also happen if the file you're trying to write to is already open by another process, or has been marked as read-only.
Dec 23 '09 #9
g diddy
54
yes it is a work machine, im not sure what the local policy with it is though so that may be the case, however i'm sure it used to work. How would I go about hard coding it to the desktop location? like say my personal drive was Y would I just simply need to change the C:\ to Y:\? As far as I know it isn't opened by another process. Later on in the code I convert from snp to pdf but as it doesn't seem to be outputting at all it isn't even getting anywhere near that stage so I don't reckon that is the problem... touch wood!
Dec 24 '09 #10
NeoPa
32,556 Expert Mod 16PB
I guess you can see that this is the answer to your question though yes? The subsequent code is never executed as the line causes an error, from which your error handling code simply returns execution to the end of the subroutine.

Some further information could be displayed from the contents of the Err object in your Error Handling routine should you wish.
Dec 24 '09 #11
g diddy
54
thanks for all your help and advice guys. i'm off work til the 4th of jan but when I get back i'm going to try a few things and see how it goes; using everything you've said to guide me. I'll let you know how it goes. thanks for your help
Dec 25 '09 #12
missinglinq
3,532 Expert 2GB
As NeoPa has pointed out, your code is causing an error, which drops you to the error handler, thus bypassing the message box. The problem is here:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acReport, MyChoiceOne, "SnapshotFormat(*.snp)", "c:\" & MyReportOne & ".snp", False, ""
Instead of acReport it should be acOutputReport, which should be popping up as a choice from Intellisense.

Linq ;0)>
Dec 26 '09 #13
g diddy
54
Thanks very much for that correction missinglinq, the error message now no longer appears. For some reason though, when I step through the code it still gets to this line and then shows the message box saying that it is outputting to file but then the code stops and when I step through again it starts at the beginning of the code. There are no error messages and everything after this line is ignored, even msgbox, and also the file is not created. I'm going to try a few things over the next few days but if anyone has any ideas that would be great. Thanks for all your time!

Edit: I changed the location from C to U (my personal drive at work) and the file outputted so the output problem may be something to do with access privelages. I've managed to get it working correctly now. Thanks very much for all your time and effort.
Jan 4 '10 #14
NeoPa
32,556 Expert Mod 16PB
That's good to hear, but it's always better to understand what's going on - especially when things don't work as required.

I sometimes find that the Error Trapping setting in the VBE can cause issues for people trying to debug. Debugging in VBA is a useful resource when thinking about debugging, but more specifically, Debugging in VBA - 3) General Tips discusses the settings that should be selected for most effective debugging.
Jan 4 '10 #15
g diddy
54
Thanks NeoPa they are very useful!
Jan 4 '10 #16
NeoPa
32,556 Expert Mod 16PB
Always a pleasure G_Diddy :)
Jan 4 '10 #17

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

Similar topics

18
by: Phill Long | last post by:
this is the the code, now here is the final result.... I get one combo box and one tex box come up, but they are empty... DAMN!!! Any ideas on what Im doing wrong please.. Thanks Again <?php...
3
by: Graham | last post by:
On page 89 of Stroustrup's book "The C++ Programming Language" 3rd Ed. He says that multidimensional arrays are best avoided outside low-level code. What precisely does he mean by low-level...
5
by: apple | last post by:
UDBV8 fp 6a - AIX 5.1 We have scheduled cron jobs to do backups. Periodically and starting to occur more frequently, a backup fails with this error: SQL2072N Unable to bind the shared library...
6
by: Wito | last post by:
hi, I want to backup database (db2, aix 5.1) using script. When I exec script logging to user db2inst1 then is everything ok, but from cron, I get these error: SQL10007N Message "-1390" could...
2
by: Tyson | last post by:
I have got this little piece of code that fires on exit of a text box. It run's my query perfectly based of my form input. But I don't know how to bring result in my query back to a text box on my...
1
by: Mitan | last post by:
Hello, I'm a beginner with what appears to be a simple question for which I haven't been able to get an answer. Can someone explain what "implementation code" is in relation to VB.NET? I want to be...
2
by: mike_li | last post by:
On Window 2000 Professional Server DB2 UDB Level: DB2 code release "SQL07029" with level identifie "030A0105" and informational tokens "DB2 v7.1.0.98", "n040510" and "WR21337". In the...
3
by: nan | last post by:
Hi All, I am trying to connect the Database which is installed in AS400 using DB2 Client Version 8 in Windows box. First i created the Catalog, then when i selected the connection type...
2
by: Coolboy55 | last post by:
Hi, I'm using the Form_Dirty event to run DoCmd.RunCommand acCmdSaveRecord, but it does not appear to be working, although the event does trigger. I want the record on the main form to be saved...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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?
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...

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.