+ Reply to Thread
Results 1 to 7 of 7

View Report (With Excel) - vba code?

  1. #1
    Forum Contributor
    Join Date
    08-06-2007
    Posts
    105

    View Report (With Excel) - vba code?

    I have a database that currently when you click the button on the form, it opens the report "rpt_Test".

    I have to then manually view it with excel and save it.

    I'm looking for a code that will do the following:

    1) Click the button on form = msgbox ("View report or export?") vbyesno
    2) Yes = View report
    2a) No = Export into S:\Testing\TestReport.xls
    2b) msgbox ("Successfully exported!")
    3) exit report view and just show form

    I tried looking through the macro commands and couldn't find anything, so i'm ok using VBA instead

    Thanks for all the help!
    Last edited by adgjqetuo; 11-20-2009 at 08:49 AM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: View Report (With Excel) - vba code?

    Hi,

    Is "rpt_test" a workbook, worksheet or range?

    Rgds
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: View Report (With Excel) - vba code?

    Hi adgjqetuo,

    Here are the VBA DoCmd codes you could use if you went with two buttons:

    To view the report:
    Please Login or Register  to view this content.
    To export the report to a file:
    Please Login or Register  to view this content.
    Cheers,
    Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.

  4. #4
    Forum Contributor
    Join Date
    08-06-2007
    Posts
    105

    Re: View Report (With Excel) - vba code?

    Quote Originally Posted by ConneXionLost View Post
    Hi adgjqetuo,

    Here are the VBA DoCmd codes you could use if you went with two buttons:

    To view the report:
    Please Login or Register  to view this content.
    To export the report to a file:
    Please Login or Register  to view this content.
    Cheers,
    Thanks for the response! The export code works perfectly only it opens the excel file too. I want it to export "behind the scenes" and not actually open - just save. I tried turning off notifications but that didn't work. Any ideas?

    Would turning auto start to "false" do the trick? I didn't think to try that earlier.

    Also, what's the access vb code for yes no message box? Is it the same as excel?

    IE:
    if msgbox ("test", vb yesno) = vbyes then
    <code>
    else
    <code>
    end if
    Last edited by adgjqetuo; 11-19-2009 at 02:20 AM.

  5. #5
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: View Report (With Excel) - vba code?

    Hi adgjqetuo,

    Try changing:

    AutoStart:=True

    to:

    AutoStart:=False

    Cheers,

  6. #6
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: View Report (With Excel) - vba code?

    Hi adgjqetuo,

    You can use a MsgBox using the syntax described here:

    MsgBox

    But you may prefer to build your own form for this purpose.

    Cheers,

  7. #7
    Forum Contributor
    Join Date
    08-06-2007
    Posts
    105

    Re: View Report (With Excel) - vba code?

    The codes you provided worked perfectly!

    The msgbox I coded above worked fine. (I'm an excel guy and wasn't sure if that code was interchangable. but apparently it is)

    Thank you!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1