ClioSport.net

Register a free account today to become a member!
Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

  • When you purchase through links on our site, we may earn an affiliate commission. Read more here.

VBA Help? (Probably easy)



mace¬

ClioSport Club Member
  Clio
OK I know nothing about VB, but I've been tasked with tidying up the reporting and changing a few things, In access they clicked a button ran some reports and emailed them off, unfortunately they get about 23 emails one after another so I decided to put them all into a folder on the network.

Now my problem is, if I just run it from a Macro it works fine, once I then try and put it to work from the button it does nothing other than prompt from the drive letter and dates. When it comes to execute the queries is does nothing.

Anyone tell me why?

So the button does this...

Code:
Private Sub Command108_Click()
    RunMonthlyStats
End Sub

Then this

Code:
Option Compare Database

Dim InputStartDate As String
Dim InputEndDate As String

Option Explicit

Public Function Output_Test()
    Dim message, title, defaultValue As String
    Dim myValue As String
    Dim Drive, My As String
    Dim fso As FileSystemObject
    
    message = "Enter the drive letter that is mapped to E-HEALTHCARESUPPORT"
    title = "Monthly Report Output Location"
    defaultValue = "S"

    myValue = InputBox(message, title, defaultValue)
    InputStartDate = InputBox("Please enter Start Date:", "Start Date")
    InputEndDate = InputBox("Please enter End Date:", "End Date")
    If myValue = "" Then myValue = defaultValue
    'Drive = "\\tsclient\" + myValue + "\05_Proj_Mgmt_Results_and_Rpts\Msmt_Data\Monthly_USD_Reporting"
    Drive = "\\fileshares.corp.hp.com\groups\e-healthcaresupport\" + myValue
    On Error Resume Next

    If Dir(Drive, vbDirectory) = "" Then
        MsgBox ("Directory does not exist: " & vbNewLine & vbNewLine & Drive)
        Exit Function
    End If
    
    DoCmd.OutputTo acOutputQuery, "zzPM_Output_Test", acFormatXLS, Drive + "\Test_Output.xls", False
    DoCmd.OutputTo acOutputQuery, "zzPM_Output_Test1", acFormatXLS, Drive + "\Test_Output1.xls", False
    
End Function




Public Function StartDate() As String
    StartDate = InputStartDate
End Function


Public Function EndDate() As String
    EndDate = InputEndDate
End Function

Thanks, I can't figure out whats changed.
 

mace¬

ClioSport Club Member
  Clio
No worries panic over, ambiguous name, forgot that I had left my original one I wrote as a test there.

So StartDate and EndDate were duplicated. i was wrong as well, once I'd duplicated them they both stopped working.
 


Top