ProperCase

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

ProperCase

Post by D Willett »

Hi. Could do with a little help with my VBA code.
I need the created folder and report to be propercase, its just a cosmetic fad of mine !!:

Code: Select all

Private Sub cmdUploadFTP_Click()
If strRole <> "SuperUser" Then
MsgBox "Only Super Users Have Access This Function", , "Restricted"
Exit Sub
End If

If Len(Dir("L:\SW-Tables\Reports\" & Me.BrowserTitle, vbDirectory)) = 0 Then
   MkDir "L:\SW-Tables\Reports\" & Me.BrowserTitle
End If

If FileExists("C:\accdata.html") Then
    
       FileCopy "C:\accdata.html", "L:\SW-Tables\Reports\" & Me.BrowserTitle & "\" & Me.BrowserTitle & "-" & Format(Me.txtStartDate, "dd-mmm-yyyy") & " To " & Format(Me.txtEndDate, "dd-mmm-yyyy") & ".html"
 

      MsgBox "Report Uploaded", , "Success"
    
    Else
    MsgBox "No Report to Upload", , "Error"
    Exit Sub
    End If

End Sub
Cheers ...

Dave.

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: ProperCase

Post by Rudi »

I'm no expert with VBA for Access, but give this a try..
Just my :2cents:

Code: Select all

Private Sub cmdUploadFTP_Click()
    If strRole <> "SuperUser" Then
        MsgBox "Only Super Users Have Access This Function", , "Restricted"
        Exit Sub
    End If

    If Len(Dir("L:\SW-Tables\Reports\" & Me.BrowserTitle, vbDirectory)) = 0 Then
        MkDir "L:\SW-Tables\Reports\" & StrConv(Me.BrowserTitle, vbProperCase)
    End If

    If FileExists("C:\accdata.html") Then
        FileCopy "C:\accdata.html", "L:\SW-Tables\Reports\" & Me.BrowserTitle & "\" & _
            StrConv(Me.BrowserTitle & "-" & Format(Me.txtStartDate, "dd-mmm-yyyy") & _
            " To " & Format(Me.txtEndDate, "dd-mmm-yyyy"), vbProperCase) & ".html"
        MsgBox "Report Uploaded", , "Success"
    Else
        MsgBox "No Report to Upload", , "Error"
        Exit Sub
    End If
End Sub
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
HansV
Administrator
Posts: 78415
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: ProperCase

Post by HansV »

Or try this, it uses strConv only once.

Code: Select all

Private Sub cmdUploadFTP_Click()
    Dim strTitle As String

    If strRole <> "SuperUser" Then
        MsgBox "Only Super Users Have Access This Function", , "Restricted"
        Exit Sub
    End If

    strTitle = StrConv(Me.BrowserTitle, vbProperCase)
    If Len(Dir("L:\SW-Tables\Reports\" & strTitle, vbDirectory)) = 0 Then
        MkDir "L:\SW-Tables\Reports\" & strTitle
    End If

    If FileExists("C:\accdata.html") Then
        FileCopy "C:\accdata.html", "L:\SW-Tables\Reports\" & _
            strTitle & "\" & strTitle & "-" & _
            Format(Me.txtStartDate, "dd-mmm-yyyy") & " To " & _
            Format(Me.txtEndDate, "dd-mmm-yyyy") & ".html"
        MsgBox "Report Uploaded", , "Success"
    Else
        MsgBox "No Report to Upload", , "Error"
    End If
End Sub
Best wishes,
Hans

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Re: ProperCase

Post by D Willett »

Cheers guys. Problem solved.

Kind Regards
Cheers ...

Dave.