Results 1 to 7 of 7

Find/Replace not working

Threaded View

  1. #1
    Forum Contributor
    Join Date
    05-13-2009
    Location
    Lincoln, IL
    MS-Off Ver
    365
    Posts
    242

    Question Find/Replace not working

    The portion of the code that replaces RESET with 1RESET, works fine on it's own, but not as part of this larger code. It doesn't error out, it just does nothing. Can someone point out what I'm missing? It's at almost the end of the code.

        Public Sub Generate_Accrued_PTO_Report()
    
    
        Application.ScreenUpdating = False
        Application.DisplayAlerts = False
    
    ' This code establishes values and formatting for the input boxes.
    '
        Dim MyInput As String
        Dim MyInput2 As String
    '    Dim MyInput3 As String
        Dim MyInput4 As String
    '    Dim MyInput5 As String
        Dim Message As String
        Dim TitlebarTxt As String
        Dim DefaultTxt As String
    
        Message = _
        "*  The Christian Village" & vbCrLf & _
        "*  Fair Havens Christian Home" & vbCrLf & _
        "*  Pleasant Meadows Christian Village" & vbCrLf & _
        "*  Lewis Memorial Christian Village" & vbCrLf & _
        "*  Hoosier Christian Village" & vbCrLf & _
        "*  Wabash Christian Retirement Center" & vbCrLf & _
        "*  Shawnee Christian Retirement Center" & vbCrLf & _
        "*  Washington Christian Village" & vbCrLf & _
        "*  Spring River Christian Village" & vbCrLf & _
        "*  Chicagoland Christian Village" & vbCrLf & _
        "*  Risen Son Christian Village" & vbCrLf & _
        "*  Heartland Christian Village" & vbCrLf & _
        "*  Hickory Point Christian Village" & vbCrLf & _
        "*  Senior Care Pharmacy Services" & vbCrLf & _
        "*  Corporate Office" & vbCrLf & _
        "*  Bridgeway Christian Village_Independent Living" & vbCrLf & _
        "*  Bridgeway Christian Village_Healthcare" & vbCrLf & _
        "*  Wabash Estates" & vbCrLf & _
        "*  Washington Village Estates"
        
        TitlebarTxt = "Location Selection"
        DefaultTxt = "Enter a location from the list above"
        
    ' This prompts the user for data that will be modified in the code below.
    '
        
        MyInput = InputBox(Message, TitlebarTxt, DefaultTxt)
        MyInput4 = InputBox("Enter File Folder (01_TCV)")
     '   MyInput3 = InputBox("Enter 2-Digit Facility Number (01)")
     '   MyInput5 = InputBox("Enter Cycle 2 Period Ending Date (2010-05-22)")
        MyInput2 = InputBox("Enter Period Ending Date (2010-05-29)")
    
    ' This code opens the Accrued PTO Query and changes the date to user specified date.
    '
        ChDir "U:\File Cabinet\K\Kronos Microsoft Queries\Accrued PTO Dollars"
        Workbooks.OpenDatabase Filename:= _
            "U:\File Cabinet\K\Kronos Microsoft Queries\Accrued PTO Dollars\Accrued_PTO_Dollars.dqy" _
            , CommandText:=Array( _
            "SELECT VP_PERSON.HOMELABORLEVELDSC1, VP_PERSON.HOMELABORLEVELDSC2, EmployeePay_Job_Curr.EmpNo, VP_PERSON.PERSONFULL" _
            , _
            "NAME, EmployeePay_Job_Curr.PayRate, VP_ACCRUALTRANV42.EFFECTIVEDATE, VP_ACCRUALTRANV42.ACCRUALTRANTYPENM, LEFT(Accr" _
            , _
            "ualTranAmount/60/60,6) AS 'AccrualTotal', VP_PERSON.HOMELABORLEVELNAME3  FROM WfcSuite.dbo.EmployeePay_Job_Curr Emp" _
            , _
            "loyeePay_Job_Curr, WfcSuite.dbo.VP_ACCRUALTRANV42 VP_ACCRUALTRANV42, WfcSuite.dbo.VP_PERSON VP_PERSON  WHERE VP_PER" _
            , _
            "SON.PERSONNUM = EmployeePay_Job_Curr.EmpNo AND VP_PERSON.PERSONNUM = VP_ACCRUALTRANV42.PERSONNUM AND ((VP_ACCRUALTR" _
            , _
            "ANV42.ACCRUALCODENAME='PTO') AND (VP_ACCRUALTRANV42.ACCRUALTRANTYPENM<>'CarryForward') AND (VP_ACCRUALTRANV42.ACCRU" _
            , _
            "ALTRANAMOUNT<>$0) AND (VP_ACCRUALTRANV42.EFFECTIVEDATE <='" & MyInput2 & "') AND (VP_PERSON.HOMELABO" _
            , _
            "RLEVELDSC1='" & MyInput & "'))  ORDER BY VP_PERSON.HOMELABORLEVELDSC2, VP_PERSON.HOMELABORLEVELNAME3, VP_PERS" _
            , "ON.PERSONFULLNAME, VP_ACCRUALTRANV42.EFFECTIVEDATE"), CommandType:=xlCmdSql _
            , ImportDataAs:=xlTable
        With ActiveWorkbook.Connections("Accrued_PTO_Dollars").ODBCConnection
            .BackgroundQuery = True
            .CommandText = Array( _
            "SELECT VP_PERSON.HOMELABORLEVELDSC1, VP_PERSON.HOMELABORLEVELDSC2, EmployeePay_Job_Curr.EmpNo, VP_PERSON.PERSONFULL" _
            , _
            "NAME, EmployeePay_Job_Curr.PayRate, VP_ACCRUALTRANV42.EFFECTIVEDATE, VP_ACCRUALTRANV42.ACCRUALTRANTYPENM, LEFT(Accr" _
            , _
            "ualTranAmount/60/60,6) AS 'AccrualTotal', VP_PERSON.HOMELABORLEVELNAME3" & Chr(13) & "" & Chr(10) & "FROM WfcSuite.dbo.EmployeePay_Job_Curr Emp" _
            , _
            "loyeePay_Job_Curr, WfcSuite.dbo.VP_ACCRUALTRANV42 VP_ACCRUALTRANV42, WfcSuite.dbo.VP_PERSON VP_PERSON" & Chr(13) & "" & Chr(10) & "WHERE VP_PER" _
            , _
            "SON.PERSONNUM = EmployeePay_Job_Curr.EmpNo AND VP_PERSON.PERSONNUM = VP_ACCRUALTRANV42.PERSONNUM AND ((VP_ACCRUALTR" _
            , _
            "ANV42.ACCRUALCODENAME='PTO') AND (VP_ACCRUALTRANV42.ACCRUALTRANTYPENM<>'CarryForward') AND (VP_ACCRUALTRANV42.ACCRU" _
            , _
            "ALTRANAMOUNT<>$0) AND (VP_ACCRUALTRANV42.EFFECTIVEDATE <='" & MyInput2 & "') AND (VP_PERSON.HOMELABO" _
            , _
            "RLEVELDSC1='" & MyInput & "'))" & Chr(13) & "" & Chr(10) & "ORDER BY VP_PERSON.HOMELABORLEVELDSC2, VP_PERSON.HOMELABORLEVELNAME3, VP_PERS" _
            , "ON.PERSONFULLNAME, VP_ACCRUALTRANV42.EFFECTIVEDATE")
            .CommandType = xlCmdSql
            .Connection = _
            "ODBC;DSN=WTK ;Description=WTK;UID=acrowe;APP=2007 Microsoft Office system;WSID=CHI102W;DATABASE=WfcSuite;Trusted_Connection=Yes"
            .RefreshOnFileOpen = False
            .SavePassword = False
            .SourceConnectionFile = ""
            .SourceDataFile = ""
            .ServerCredentialsMethod = xlCredentialsMethodIntegrated
            .AlwaysUseConnectionFile = False
        End With
        With ActiveWorkbook.Connections("Accrued_PTO_Dollars")
            .Name = "Accrued_PTO_Dollars"
            .Description = ""
        End With
        ActiveWorkbook.Connections("Accrued_PTO_Dollars").Refresh
    
    'This code auto replaces Reset with 1Reset
    '
            Columns("g:g").Select
            Selection.Replace What:="RESET", Replacement:="1RESET", LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
            ReplaceFormat:=False
        
    ' This code formats the table data.
    
    
    
    
        
    'This code creates the pivot table.
    '
    '    Call Accrued_PTO_Pivot_Table
        
    'This code saves the report.
    '
    '    Call Accrued_PTO_Save
        
    '    Application.DisplayAlerts = True
    
        
    End Sub
    Last edited by narrowgate88; 06-07-2010 at 02:26 PM.

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