Results 1 to 13 of 13
  1. #1
    Join Date
    Feb 2007
    Posts
    348

    Talking Unanswered: using outputTo, bragging

    This is almost certainly indicative of just how bad I am at this but I spent a couple hours coming up with this single line of code and I'm darn proud of myself. I don't know anyone who knows anything about this stuff and I had to tell someone. So this is my little piddly brag. I wrote this:

    Code:
    DoCmd.OutputTo acOutputReport, Screen.ActiveReport.Name, acFormatRTF, "C:\Documents and Settings\" & UserID & "\Desktop\" & Screen.ActiveReport.Name & Year(Now) & Month(Now) & Day(Now) & ".doc", True
    I realize there is an export function in access but my folks love to try and circumvent any protections I build into an Access project. So this one is pretty much locked down. I got a request to be able to export to a word document and this is what I came up with. What's more, I plugged it into a macro which is now on my custom toolbar that I actually let them use. So now, from any report they can export to word.
    I know it's not much but I did it on my own and I like it. It's probably my first module that can stand on it's own and be exported and imported to different access apps I am working on.

    Thanks for letting me brag and feel good.
    If I'm missing something very bad here, it's okay to point it out. I'd rather here it from you guys.

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Apart from one tiny-weeney little detail that is great!
    It just goes to show that you are seriously getting the hand of this Access / VBA M'larky! Good on you mate and keep up the good work!

    Tiny little thing: Macros suck
    George
    Home | Blog

  3. #3
    Join Date
    Feb 2007
    Posts
    348
    Thanks George.:-)
    I might have missed something here but the reason I plugged the code into a macro was because I was able to make a toolbar button out of the macro that I didn't see a way to do with just a module. Is there a way to point a toolbar button at a module?

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by starkmann
    Is there a way to point a toolbar button at a module?
    http://www.dbforums.com/showthread.php?t=1618905
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    I'm not a fan of macros either. But I am old & stuck in my ways

    Nor am I a big fan of DoCmd.

    For 10 points - anyone know what the DoCmd object's methods directly parallel?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  6. #6
    Join Date
    Feb 2007
    Posts
    348
    Thanks for the link poodle. ill be interested to know how to do it without docmd.

  7. #7
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by starkmann
    Thanks for the link poodle
    *rofl*
    The reason I hate macros : no error handling!
    Anything you can create in a macro can be coded in a module (you can even right-click > Save as...) and error handling can be applied there

    I have never come across any real problems with DoCmd and I don't think I can think of the "parallel". A wild stab would be aimed at Action

    ...After looking in the help files - Action doesn't look nearly right
    George
    Home | Blog

  8. #8
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Every* DoCmd method has a macro parallel. I'm not mad keen on DoCmd because it abstracts so much away from the developer. Anyone who starts out using Access without trying another development environment\ language thinks that forms are totally distinct from everything else in the database rather than a class with a gui. Admittedly VB is somewhat to blame here too. You rarely see form instantiated in Access as in the link I posted.

    I'm not saying don't use DoCmd nor that I have a library the replicates everything it does. I don't know any other way to do what you do. But for some of the methods I prefer my home rolled stuff because I have so much more control. Anyway - enough of the half-hearted rant.

    * or pretty well every - never cross referenced

    Quote Originally Posted by georgev
    *rofl*
    Happens a lot
    Testimonial:
    pootle flump
    ur codings are working excelent.

  9. #9
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    Every* DoCmd method has a macro parallel
    I'm a little lost here... I thought the macros used the DoCmd method too? Certainly when you save them as modules that's the VBA code. Penny hasn't quite dropped yet (it's an odd saying that) but who can blame me - the week has already been far too long.
    George
    Home | Blog

  10. #10
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by georgev
    I thought the macros used the DoCmd method too?
    It's the other way around:
    Quote Originally Posted by Access Help
    You can use the methods of the DoCmd object to run Microsoft Access actions (action: The basic building block of a macro; a self-contained instruction that can be combined with other actions to automate tasks. This is sometimes called a command in other macro languages.) from Visual Basic. An action performs tasks such as closing windows, opening forms, and setting the value of controls.
    Note your guess was more accurate than what I said

    I wanted to inially say "DoCmd runs macros for you" (confusing macros and actions) but I'm a but rusty and couldn't remember if that was strictly accurate so I talked about parallels. After RingTFM it is all clarified.

    I suppose I can now more accurately say that, where possible, I like to avoid using Access actions (be it via the DoCmd or macro)

    Another reason i remembered - proprietry. You can't port a DoCmd call to another language very easily whereas I plan to upgrade, for example, my excel automation code to .NET.... one day.

    Anyway - we are way OT. Sorry Starkman - was the link helpful?
    Last edited by pootle flump; 06-06-07 at 06:15.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  11. #11
    Join Date
    Feb 2007
    Posts
    348
    no worries on the off topic, I'm following right along.
    I work in access and VBA today but I have learning VB as a goal for the next 12 months so the stuff abotu porting and so on was great.

    I read the link and think I follow you. That discussion, as I understood it, pointed out that the form menus can be manipulated. In that case it was the right click, which would be a cool way to implement this snippet. Presumably that could be extened to the toolbars and other menus.

    did I get that right?

  12. #12
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by starkmann
    no worries on the off topic, I'm following right along.
    I work in access and VBA today but I have learning VB as a goal for the next 12 months so the stuff abotu porting and so on was great.
    Classic or .NET? If you are thinking about your CV I would try to move on to .NET instead. Of course there will be work for years to come for classic but not as much as .NET. I don't think I've touched visual studio 6 since I got visual studio 2003...

    Quote Originally Posted by starkmann
    I read the link and think I follow you. That discussion, as I understood it, pointed out that the form menus can be manipulated. In that case it was the right click, which would be a cool way to implement this snippet. Presumably that could be extened to the toolbars and other menus.

    did I get that right?
    exact-a-bloody-lutely
    Thinking of doing the same in my current hobby\ favour project.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  13. #13
    Join Date
    Feb 2007
    Posts
    348
    I have the book for 2005, but that was just the one I was given. I have been debating if I wanted to shell out for .net. I probably should.

    The menus will be fun to play with. I'm building up to a largish job. Maybe not large on you all's level but large or at least complicated to me. A multi user (no more than 15) access app that basically does all of the issue/task tracking for my office.
    The data isn't too heavy but it'll be complex and some of my folks need it to be totally intuitive. Others will do all they can to break it, of course with the best of intentions.
    Being able to strictly control the menus and right click will make this much easier.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •