Results 1 to 2 of 2
  1. #1
    Jmeyering is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    10

    VBA code exiting no error.

    Can anyone lend a hand and help me figure out why my VBA script is quitting in the middle of a script?



    Code:
    Sub Test 
    Dim rst As DAO.RecordsetDim strReport As String
    Dim rptSavePath As String
    Dim EmailAddress As String
    
    
    Set rst = CurrentDb.OpenRecordset("SELECT DISTINCT [ClientID] FROM [tblPettyCashTransactions] ORDER BY [ClientID];", dbOpenSnapshot)
    strReport = "rptPettyCash"
    
    
    rptSavePath = "C:\rptsave\"
    If Dir(rptSavePath) = Null Then
        MkDir rptSavePath
    End If
    rptSavePath = rptSavePath & rst![ClientID] & " PettyCash.pdf"
    
    
    Do While Not rst.EOF
        rptSavePath = "C:\rptsave\" & rst![ClientID] & " PettyCash.pdf"
        
        If Not Dir(rptSavePath) = "" Then
        Kill (rptSavePath)
        End If
        
        strRptFilter = "[ClientID] = " & rst![ClientID]
        DoCmd.OutputTo acOutputReport, strReport, acFormatPDF, rptSavePath ' Completes this action successfully but never moves on.
    
    rst.MoveNext
    Loop
    
    
    rst.Close
    Set rst = Nothing
    
    End Sub
    I've marked where the sub just quits. There are no message boxes and nothing seems to go wrong, everything works great so far.

  2. #2
    Jmeyering is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    10
    The error was in my report on close function that was exiting the sub early.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. code logic error
    By mejia.j88 in forum Programming
    Replies: 17
    Last Post: 03-27-2012, 10:03 PM
  2. Code results in error on the first day of every month
    By boomerang in forum Programming
    Replies: 6
    Last Post: 11-05-2011, 11:29 AM
  3. Copy Database Code Error
    By Tomfernandez1 in forum Programming
    Replies: 5
    Last Post: 05-03-2011, 12:21 PM
  4. Error in form code
    By devesa in forum Access
    Replies: 3
    Last Post: 05-25-2010, 10:15 AM
  5. Error in Code
    By Lockrin in forum Programming
    Replies: 3
    Last Post: 02-25-2010, 03:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums