Results 1 to 10 of 10

Thread: DoCmd. Help

  1. #1
    Join Date
    Sep 2009
    Posts
    7

    Unanswered: DoCmd. Help

    Hi,

    I have been able to export a report in snapshot format with todays date included in the filename. Is it possible to amend this so instead of todays date being used Access use's the date that I have entered into a form?

    My current code is:

    TheDate = Year(Date) & "-" & Month(Date) & "-" & Day(Date)


    TheFile = "File Location" & TheDate & ".snp"

    DoCmd.OutputTo acOutputReport, "rpt_agent_broadsheet_jamie", "SnapshotFormat(*.snp)", TheFile, False, ""

    TheMessage = "Report has been exported to " & TheFile


    Beep
    MsgBox TheMessage, vbInformation, "Report Complete"


    End Sub

    Thanks

    Dan

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    TheFile = "File Location" & forms!myformname!mycontrolname & ".snp"

    or if the code is running from the same form
    TheFile = "File Location" & mycontrolname & ".snp"
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Sep 2009
    Posts
    7
    Thanks for this, I have tried with both codes and it seems to be hitting a snag, Im quite new to this so still trying to find my feet.

    Ive amended the code to the following

    TheFile = "File Location" & Forms!frm_Reports!Report_run_date & ".snp"

    DoCmd.OutputTo acOutputReport, "rpt_agent_broadsheet_jamie", "SnapshotFormat(*.snp)", TheFile, False, ""

    When I run this it stops on the DoCmd section when I debug. What am I missing?

    Thanks again for your help.

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    i don't know
    have you looked at what the variable thefile is now defined as
    is it a valid filename?
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Sep 2009
    Posts
    7
    Yeah its a valid filename, When I run I get the following message.

    Run-time Error 2024, The report snapshot was not created because you dont have enough free disk space for temporary work files. When I select Debug it highlights in yellow the DoCmd section.

    I have changed the code back to its original function (putting todays date in the savefile name) and it works fine so I cant see what is causing it to fail now??

    Thanks

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so the old code works fine, the new code doesn't
    the new code craps out with a out of space error.

    so it suggests to mne there something hooky with the file name
    what values are you getting for the filename
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Sep 2009
    Posts
    7
    Sorry what do you mean values am i getting for the filename?

  8. #8
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    having built your filename what is it set to
    what value is assigned to 'thefile'
    I'd rather be riding on the Tiger 800 or the Norton

  9. #9
    Join Date
    Sep 2009
    Posts
    7
    TheFile = "\\CCFILE-SRV-A\Fileshare\Chatham\T Docs\Sunday Relaunch\Team Coaches\Customer Service Records\Jamie Nightingale\Daily Broadsheets\Daily Broadsheet_" & Forms!frm_Reports!Report_run_date & ".snp"

    Bit of a long file name I know. I have googled error 2024 and tried lots of error fixing hints such as saving to my local drive, checking the disk space, reducing the number of files it has to access, Im the owner of the folder and it sits on a network drive and yet the file section seems to be ok and when I hover over the segments it shows the correct details, im flummoxed !

    Thanks

  10. #10
    Join Date
    Sep 2009
    Posts
    7
    Thought I would include all the text on this.

    TheDate = Year(Date) & "-" & Month(Date) & "-" & Day(Date)

    TheFile = "\\CCFILE-SRV-A\Fileshare\Chatham\T Docs\Sunday Relaunch\Team Coaches\Customer Service Records\Jamie Nightingale\Daily Broadsheets\Daily Broadsheet_" & Forms!frm_Reports!Report_run_date & ".snp"

    DoCmd.OutputTo acOutputReport, "rpt_agent_broadsheet_Jamie", acFormatSNP, TheFile, False, ""

    Thanks

Posting Permissions

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