J.R. Sitman
asked on
Can't connect to FTP site from Microsoft Access
Could you post your Operating System and the version of Access you are currently using?
ASKER
here is the code, minus the passwords
Option Compare Database
Option Explicit
Private Sub cboLocation_AfterUpdate()
Me.Requery
End Sub
Private Sub cmdFTP_Click()
Dim strAccount As String
Dim strPassword As String
Dim strDest As String
Const conRover = "ftp://ftp.storagemadeeasy.com"
Const conActiv4Pets = "spcala@activ4pets.com"
On Error GoTo Proc_Error
' initialize paths for different locations
Select Case Me.cboLocation
  Case "Long Beach"
    strAccount = "CA366"
    strPassword = "54"
    SPCALAExport strAccount, strPassword
    Exit Sub
   Â
  Case "South Bay"
    strAccount = "CA1612"
    strPassword = "50z"
    SPCALAExport strAccount, strPassword
    Exit Sub
   Â
  Case "Pico Rivera"  ' Pico credentials.  Note that if the account is  Ca2356, the text file uploaded should be named Ca2353.txt (it should match the account) **********
    strAccount = "CA2356"
    strPassword = "222222"
    SPCALAExport strAccount, strPassword
    Exit Sub
   Â
  Case "SPCALA Webpage"
    strAccount = "@spcala.com"
    strPassword = ""
    SPCALAExport strAccount, strPassword
    Exit Sub
   Â
  Case "Finding Rover"
    strAccount = "laspca@findingrover"
    strPassword = "laspcafindingR0ver"
    FindingRoverExport conRover, strAccount, strPassword
    Exit Sub
   Â
  Case "activ4pets"
    strDest = conActiv4Pets
    Activ4PetsExport (strDest)
    Exit Sub
 Â
  Case Else
    MsgBox "Please select Long Beach or South Bay as location, or select SPCALA Webpage"
    Exit Sub
End Select
PROC_EXIT:
  On Error Resume Next
  Exit Sub
 Â
Proc_Error:
  MsgBox "Error " & Err.Number & " in cmdFTP_Click:" & vbCrLf & Err.Description
  Resume PROC_EXIT
End Sub
Sub InitFTPObject(objFTP As FTP, strPath As String, strPage As String, strDest As String, strAccount As String, strPassword As String)
    With objFTP
      .SourceFile = strPath
      .FtpURL = strPage
      .DestinationFile = strDest
      .AutoCreateRemoteDir = False
      .ConnectToFTPHost strAccount, strPassword
      .UploadFileToFTPServer
    End With
End Sub
Private Sub SPCALAExport(strAccount As String, strPassword As String)
Dim objFTP As FTP
Dim strPath As String
Dim imgPath As String
Dim ftpPath As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rsFail As DAO.Recordset
Dim ErrCount As Integer
Const conTARGET = "ftp://members.petfinder.com"
Const conRover = "ftp://ftp.storagemadeeasy.com"
Const conWEBPAGE = "ftp://spcala.com"
Const PathName = "\\databases\access2015\Pe tfinder"
On Error GoTo Proc_Error
' initialize progress tracking textboxes
Me!txtAvailable = Me.RecordsetClone.RecordCo unt
If Me.cboLocation = "SPCALA Webpage" Then
  Me!txtAvailable = DCount("*", "qryWebpageExport")
End If
Me!txtSent = 0
Me!txtNoPic = 0
Me!txtTotal = 0
ErrCount = 0
' export the query
If Me.cboLocation = "SPCALA Webpage" Then
  strPath = PathName & "\adoptable.txt"
  'Application.ExportXML ObjectType:=acExportQuery, _
  'DataSource:="qryWebpageEx port", _
  'datatarget:=strPath
  DoCmd.TransferText acExportDelim, "Webpage Export Specification", _
   "qryWebpageExport", strPath, True
  Set objFTP = New FTP
  With objFTP
    .SourceFile = strPath
    .FtpURL = conWEBPAGE
    .DestinationFile = "adoptable.txt"
    .AutoCreateRemoteDir = False
    .ConnectToFTPHost strAccount, strPassword
    .UploadFileToFTPServer
  End With
Else
  strPath = PathName & "\" & strAccount & ".txt"
  DoCmd.TransferText acExportDelim, "Petfinder Export Specification", "qryPetfinderExport", strPath, True
  Set objFTP = New FTP
  With objFTP
    .SourceFile = strPath
    .FtpURL = conTARGET
    .DestinationFile = "/import/" & strAccount & ".txt"
    .AutoCreateRemoteDir = False
    .ConnectToFTPHost strAccount, strPassword
    .UploadFileToFTPServer
  End With
End If
'export all pictures
imgPath = DLookup("DefaultImagePath" , "tbl_ImageDefaultPath", "ImageType='SoftSlips'")
Set db = CurrentDb
Set rsFail = db.OpenRecordset("tblPetfi nderFailur es", dbOpenDynaset)
If Me.cboLocation = "SPCALA Webpage" Then
  Set rs = db.OpenRecordset("qryWebpa geExport", dbOpenDynaset)
Else
  Set rs = Me.RecordsetClone
End If
rs.MoveFirst
With objFTP
  If Me.cboLocation = "SPCALA Webpage" Then
    .FtpURL = conWEBPAGE
  Else
    .FtpURL = conTARGET
  End If
  .ConnectToFTPHost strAccount, strPassword
End With
' set initial ftp
If Me.cboLocation = "SPCALA Webpage" Then
  ftpPath = ""
Else
  ftpPath = "/import/photos/"
End If
Do Until rs.EOF
TryAgain:
  If Len(rs!SoftSlipPicPathFile & "") <> 0 Then
    If Dir(rs!SoftSlipPicPathFile ) <> "" Then
      If Me.cboLocation <> "SPCALA Webpage" Then
        Me.Bookmark = rs.Bookmark
      End If
      With objFTP
        '.SourceFile = imgPath & "\" & rs!SoftSlip & ".jpg"
        .SourceFile = rs!SoftSlipPicPathFile
        .DestinationFile = ftpPath & rs!SoftSlip & ".jpg"
        .UploadFileToFTPServer
      End With
      ' since the focus is now on the photos folder, we don't need the path any more
      'If Me.cboLocation <> "SPCALA Webpage" Then
        ftpPath = ""
      'End If
      Me!txtUploading = rs!SoftSlip
      Me!txtSent = Me!txtSent + 1
    Else
      Me!txtNoPic = Me!txtNoPic + 1
    End If
  Else
    Me!txtNoPic = Me!txtNoPic + 1
  End If
  Me!txtTotal = Me!txtTotal + 1
  Me.Repaint
  rs.MoveNext
Loop
PROC_EXIT:
  On Error Resume Next
  Set objFTP = Nothing
  Exit Sub
 Â
Proc_Error:
  Select Case Err.Number
    Case -2147219289 ' FTP switching to binary
      'MsgBox "FTP switching to binary, retrying " & rs!SoftSlip
      ErrCount = ErrCount + 1
      If ErrCount < 6 Then
        With objFTP
          If Me.cboLocation = "SPCALA Webpage" Then
            .FtpURL = conWEBPAGE
          Else
            .FtpURL = conTARGET
          End If
          .ConnectToFTPHost strAccount, strPassword
        End With
        Resume TryAgain
      Else
        ' msgbox commented out per JR's request
        'MsgBox "Too many FTP errors for " & rs!SoftSlip & ", skipping to next picture"
        rsFail.AddNew
          rsFail!SoftSlip = rs!SoftSlip
          rsFail!faildate = Now
        rsFail.Update
       Â
        ErrCount = 0
        rs.MoveNext
        If rs.EOF Then
          Resume PROC_EXIT
        Else
          Resume TryAgain
        End If
      End If
    Case Else
      MsgBox "Error " & Err.Number & " in cmdFTP_Click:" & vbCrLf & Err.Description
  End Select
  Resume PROC_EXIT
End Sub
Private Sub Form_Current()
' Update image for this animal
Dim strPath As String
Dim strFile As String
On Error Resume Next
strPath = DLookup("DefaultImagePath" , "tbl_ImageDefaultPath", "ImageType='SoftSlips'")
'strFile = strPath &Â "\" &Â Me!SoftSlip &Â ".jpg"
strFile = Nz(Me!SoftSlipPicPathFile, strPath &Â "\NoPicture.jpg")
If Dir(strFile) <>Â "" Then
  Me.imgAnimalPicture.Pictur e = strFile
End If
End Sub
Private Sub cmdClose_Click()
On Error GoTo Err_cmdclose_Click
  DoCmd.close
Exit_cmdclose_Click:
  Exit Sub
Err_cmdclose_Click:
  MsgBox Err.Description
  Resume Exit_cmdclose_Click
 Â
End Sub
Sub FindingRoverExport(strTARG ET As String, strAccount As String, strPassword As String)
  Dim strPath As String
  Dim strZip As String
  Dim strTxt As String
  Dim strTo As String
  Dim strTitle As String
  Dim strMsg As String
  Dim strSQL As String
  Dim rs As DAO.Recordset
  Dim rsHistory As DAO.Recordset
  Dim s As String
  Dim i As Integer
  Dim arrPic() As String
  Dim strRoverPicPath As String
  Dim strRoverPic As String
  Dim objFTP As FTP
 Â
  '*************  File paths **************************
  strRoverPicPath = "" & DLookup("Rover", "tblPaths")
  strPath = "C:\Paw Trax\FindingRoverFiles"
  strZip = "C:\Paw Trax\FindingRoverFiles\Fin dingRover. zip"
  strTxt = "C:\Paw Trax\FindingRoverFiles\Fin dingRover. txt"
  '************************* ********** ********** *********
 Â
  On Error Resume Next
  DoCmd.Hourglass True
  If Dir(strPath & "\") & "" = "" Then
    MkDir strPath
  Else
    Kill strZip
    Kill strTxt
   Â
  End If
  On Error GoTo PROC_ERR
 Â
  strSQL = "DELETE * FROM tblTEMPFindingRover"
  CurrentDb.Execute strSQL, dbFailOnError + dbSeeChanges
  Do Until DCount("*", "tblTEMPFindingRover") = 0
    DoEvents
  Loop
 Â
  If DCount("*", "qryFindingRoverUpdates") = 0 Then
    MsgBox "There are no new or updated records to send"
    GoTo PROC_EXIT
  End If
 Â
  'DoCmd.OpenReport "rptFindingRoverUpdates", acViewPreview
  '  Save report in PDF format, and open it for display
  DoCmd.OutputTo acOutputReport, "rptFindingRoverUpdates", acFormatPDF, strPath & "\" & Format(Now, "yyyymmddhhnnss") & "_FindingRover.pdf", True
  DoCmd.OpenQuery "qryupdFindingRoverExport"
  DoEvents
 Â
  strSQL = "SELECT SoftSlip, Pic, EncodedImage FROM tblTEMPFindingRover WHERE Pic & '' <> '' AND pic NOT LIKE '*NoImage*'"
  Set rs = CurrentDb.OpenRecordset(st rSQL, dbOpenDynaset, dbSeeChanges)
  Do Until rs.RecordCount = 0 Or rs.EOF
    'arrPic = Split(rs("Pic"), "\")
    arrPic = Split(rs("Pic"), "Pet-Ark\")
    strRoverPic = strRoverPicPath & arrPic(UBound(arrPic))
    s = Replace(Replace(ImageToBas e64Encoded (strRoverP ic), Chr(10), ""), Chr(13), "")
    If s <> "COULD NOT ENCODE SPECIFIED FILE" Then
      rs.Edit
      rs("EncodedImage") = s
      rs.Update
    End If
    rs.MoveNext
  Loop
 Â
 Â
  strPath = strPath & "\FindingRover"
 Â
  ' Export query to csv and put it in a zip file
  DoCmd.TransferText acExportDelim, "FindingRoverExport", "tblTEMPFindingRover", strTxt, True
  Zip strZip, strTxt
 Â
  ' ftp text file to finding rover
  ' strPath = PathName & "\" & strAccount & ".txt"
  DoCmd.TransferText acExportDelim, "FindingRoverExport", "tblTEMPFindingRover", strTxt, True
  Set objFTP = New FTP
  With objFTP
    .SourceFile = strTxt
    .FtpURL = strTARGET
    .DestinationFile = "/Shelters/LASPCAProd/" & Format(Now, "yyyymmddhhnnss") & "_FindingRover" & ".txt"
    .AutoCreateRemoteDir = False
    .ConnectToFTPHost strAccount, strPassword
    .UploadFileToFTPServer
  End With
  Â
  MsgBox "Data sent to Finding Rover"
  ' Attach Zip file to email
  ' 2015-10-22 -- replaced the email code with the above FTP code.
  'strTo = ""
  'strTitle = "Finding Rover Files"
  'strMsg = "See attached."
  'SendEmail strTo, strMsg, strTitle, strZip
 Â
 Â
 Â
  ' Update/Add changed or new records to history table
  strSQL = "SELECT * FROM qryFindingRoverUpdates"
  Set rs = CurrentDb.OpenRecordset(st rSQL, dbOpenDynaset, dbSeeChanges)
  Do Until rs.RecordCount = 0 Or rs.EOF
    strSQL = "SELECT * FROM tblFindingRoverHistory WHERE SoftSlip = '" & rs("SoftSlip") & "'"
    Set rsHistory = CurrentDb.OpenRecordset(st rSQL, dbOpenDynaset, dbSeeChanges)
    With rsHistory
      If .RecordCount = 0 Then .AddNew Else .Edit
      For i = 0 To (rs.Fields.Count - 1)
        .Fields(i) = rs.Fields(i)
      Next
      !DateSent = Now()
      .Update
    End With
    rsHistory.close
    Set rsHistory = Nothing
    rs.MoveNext
  Loop
 Â
 Â
PROC_EXIT:
  DoCmd.Hourglass False
 Â
 Â
  On Error Resume Next
  rs.close
  Set rs = Nothing
  strSQL = "DELETE * FROM tblTEMPFindingRover"
  CurrentDb.Execute strSQL, dbFailOnError + dbSeeChanges
 Â
  Exit Sub
PROC_ERR:
  If Err.Number = 2501 Then GoTo PROC_EXIT
  MsgBox "ERROR " & Err.Number & ": " & Err.Description
  GoTo PROC_EXIT
End Sub
Sub Activ4PetsExport(strDest As String)
  Dim strPath As String
  'Dim strZip As String
  Dim strTxt As String
  Dim strTo As String
  Dim strTitle As String
  Dim strMsg As String
  Dim strSQL As String
  Dim rs As DAO.Recordset
  Dim rsHistory As DAO.Recordset
  Dim i As Integer
 Â
  '*************  File paths Miriam **************************
  'strPath = "C:\Users\Surf\Documents\d bApps\PawT rax\Findin gRoverFile s"
  'strZip = "C:\Users\Surf\Documents\d bApps\PawT rax\Findin gRoverFile s\activ4pe ts.zip"
  'strTxt = "C:\Users\Surf\Documents\d bApps\PawT rax\Findin gRoverFile s\activ4pe ts.xlsx"
  '************************* ********** ********** *********
 Â
  '*************  File paths Production **************************
  strPath = "C:\Paw Trax\FindingRoverFiles"
  'strZip = "C:\Paw Trax\FindingRoverFiles\act iv4pets.zi p"
  strTxt = "C:\Paw Trax\FindingRoverFiles\act iv4pets.xl sx"
  '************************* ********** ********** *********
 Â
  On Error Resume Next
  DoCmd.Hourglass True
  If Dir(strPath & "\") & "" = "" Then
    MkDir strPath
  Else
    'Kill strZip
    Kill strTxt
   Â
  End If
  On Error GoTo PROC_ERR
 Â
  If DCount("*", "qryActiv4PetsUpdates") = 0 Then
    MsgBox "There are no new or updated records to send"
    GoTo PROC_EXIT
  End If
  'DoCmd.OpenReport "rptFindingRoverUpdates", acViewPreview
  '  Save report in PDF format, and open it for display
  'DoCmd.OutputTo acOutputReport, "activ4petsUpdates", acFormatPDF, strPath & "\" & Format(Now, "yyyymmddhhnnss") & "_FindingRover.pdf", True
  'DoCmd.OpenQuery "qryupdactiv4petsExport"
  'DoEvents
  ' strPath = strPath & "\FindingRover"
 Â
  ' Export query to csv and put it in a zip file
  'DoCmd.TransferText acExportDelim, "FindingRoverExport", "tblTEMPFindingRover", strTxt, True
  'Zip strZip, strTxt
 Â
  ' ftp text file to finding rover
  'strPath = PathName & "\" & strAccount & ".txt"
  'DoCmd.TransferText acExportDelim, "FindingRoverExport", "tblTEMPFindingRover", strTxt, True
  'Set objFTP = New FTP
  'With objFTP
  '   .SourceFile = strTxt
  '   .FtpURL = strTARGET
  '   .DestinationFile = "/Shelters/LASPCAProd/" & Format(Now, "yyyymmddhhnnss") & "_FindingRover" & ".txt"
  '   .AutoCreateRemoteDir = False
  '   .ConnectToFTPHost strAccount, strPassword
  '   .UploadFileToFTPServer
  'End With
  Â
  ExcelExport strTxt, "SoftSlip Info", "SELECT * FROM qryActiv4PetsToSend"
  ExcelExport strTxt, "Medical Procedures", "SELECT * FROM qryActiv4PetsProcedures"
  ExcelExport strTxt, "Medications And Vaccinations", "SELECT * FROM qryActiv4PetsMedications"
  ExcelExport strTxt, "Vet Notes", "SELECT * FROM qryActiv4PetsNotes"
 Â
  'MsgBox "Data sent to active4Pets"
  ' Attach Zip file to email
  ' 2015-10-22 -- replaced the email code with the above FTP code.
  'Zip strZip, strTxt
  strTitle = "SPCALA Paw Trax Export"
  strMsg = "See attached."
  SendEmail strDest, strMsg, strTitle, strTxt
 Â
 Â
  ' Update/Add changed or new records to history table
  strSQL = "SELECT * FROM qryActiv4PetsUpdates"
  Set rs = CurrentDb.OpenRecordset(st rSQL, dbOpenDynaset, dbSeeChanges)
  Do Until rs.RecordCount = 0 Or rs.EOF
    strSQL = "SELECT * FROM tblActiv4PetsHistory WHERE SoftSlip = '" & rs("SoftSlip") & "'"
    Set rsHistory = CurrentDb.OpenRecordset(st rSQL, dbOpenDynaset, dbSeeChanges)
    With rsHistory
      If .RecordCount = 0 Then .AddNew Else .Edit
      For i = 0 To (rs.Fields.Count - 1)
        .Fields(i) = rs.Fields(i)
      Next
      !DateSent = Now()
      .Update
    End With
    rsHistory.close
    Set rsHistory = Nothing
    rs.MoveNext
  Loop
 Â
 Â
PROC_EXIT:
  DoCmd.Hourglass False
  Exit Sub
 Â
  On Error Resume Next
PROC_ERR:
  If Err.Number = 2501 Then GoTo PROC_EXIT
  MsgBox "ERROR " & Err.Number & ": " & Err.Description
  GoTo PROC_EXIT
End Sub
Option Compare Database
Option Explicit
Private Sub cboLocation_AfterUpdate()
Me.Requery
End Sub
Private Sub cmdFTP_Click()
Dim strAccount As String
Dim strPassword As String
Dim strDest As String
Const conRover = "ftp://ftp.storagemadeeasy.com"
Const conActiv4Pets = "spcala@activ4pets.com"
On Error GoTo Proc_Error
' initialize paths for different locations
Select Case Me.cboLocation
  Case "Long Beach"
    strAccount = "CA366"
    strPassword = "54"
    SPCALAExport strAccount, strPassword
    Exit Sub
   Â
  Case "South Bay"
    strAccount = "CA1612"
    strPassword = "50z"
    SPCALAExport strAccount, strPassword
    Exit Sub
   Â
  Case "Pico Rivera"  ' Pico credentials.  Note that if the account is  Ca2356, the text file uploaded should be named Ca2353.txt (it should match the account) **********
    strAccount = "CA2356"
    strPassword = "222222"
    SPCALAExport strAccount, strPassword
    Exit Sub
   Â
  Case "SPCALA Webpage"
    strAccount = "@spcala.com"
    strPassword = ""
    SPCALAExport strAccount, strPassword
    Exit Sub
   Â
  Case "Finding Rover"
    strAccount = "laspca@findingrover"
    strPassword = "laspcafindingR0ver"
    FindingRoverExport conRover, strAccount, strPassword
    Exit Sub
   Â
  Case "activ4pets"
    strDest = conActiv4Pets
    Activ4PetsExport (strDest)
    Exit Sub
 Â
  Case Else
    MsgBox "Please select Long Beach or South Bay as location, or select SPCALA Webpage"
    Exit Sub
End Select
PROC_EXIT:
  On Error Resume Next
  Exit Sub
 Â
Proc_Error:
  MsgBox "Error " & Err.Number & " in cmdFTP_Click:" & vbCrLf & Err.Description
  Resume PROC_EXIT
End Sub
Sub InitFTPObject(objFTP As FTP, strPath As String, strPage As String, strDest As String, strAccount As String, strPassword As String)
    With objFTP
      .SourceFile = strPath
      .FtpURL = strPage
      .DestinationFile = strDest
      .AutoCreateRemoteDir = False
      .ConnectToFTPHost strAccount, strPassword
      .UploadFileToFTPServer
    End With
End Sub
Private Sub SPCALAExport(strAccount As String, strPassword As String)
Dim objFTP As FTP
Dim strPath As String
Dim imgPath As String
Dim ftpPath As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rsFail As DAO.Recordset
Dim ErrCount As Integer
Const conTARGET = "ftp://members.petfinder.com"
Const conRover = "ftp://ftp.storagemadeeasy.com"
Const conWEBPAGE = "ftp://spcala.com"
Const PathName = "\\databases\access2015\Pe
On Error GoTo Proc_Error
' initialize progress tracking textboxes
Me!txtAvailable = Me.RecordsetClone.RecordCo
If Me.cboLocation = "SPCALA Webpage" Then
  Me!txtAvailable = DCount("*", "qryWebpageExport")
End If
Me!txtSent = 0
Me!txtNoPic = 0
Me!txtTotal = 0
ErrCount = 0
' export the query
If Me.cboLocation = "SPCALA Webpage" Then
  strPath = PathName & "\adoptable.txt"
  'Application.ExportXML ObjectType:=acExportQuery,
  'DataSource:="qryWebpageEx
  'datatarget:=strPath
  DoCmd.TransferText acExportDelim, "Webpage Export Specification", _
   "qryWebpageExport", strPath, True
  Set objFTP = New FTP
  With objFTP
    .SourceFile = strPath
    .FtpURL = conWEBPAGE
    .DestinationFile = "adoptable.txt"
    .AutoCreateRemoteDir = False
    .ConnectToFTPHost strAccount, strPassword
    .UploadFileToFTPServer
  End With
Else
  strPath = PathName & "\" & strAccount & ".txt"
  DoCmd.TransferText acExportDelim, "Petfinder Export Specification", "qryPetfinderExport", strPath, True
  Set objFTP = New FTP
  With objFTP
    .SourceFile = strPath
    .FtpURL = conTARGET
    .DestinationFile = "/import/" & strAccount & ".txt"
    .AutoCreateRemoteDir = False
    .ConnectToFTPHost strAccount, strPassword
    .UploadFileToFTPServer
  End With
End If
'export all pictures
imgPath = DLookup("DefaultImagePath"
Set db = CurrentDb
Set rsFail = db.OpenRecordset("tblPetfi
If Me.cboLocation = "SPCALA Webpage" Then
  Set rs = db.OpenRecordset("qryWebpa
Else
  Set rs = Me.RecordsetClone
End If
rs.MoveFirst
With objFTP
  If Me.cboLocation = "SPCALA Webpage" Then
    .FtpURL = conWEBPAGE
  Else
    .FtpURL = conTARGET
  End If
  .ConnectToFTPHost strAccount, strPassword
End With
' set initial ftp
If Me.cboLocation = "SPCALA Webpage" Then
  ftpPath = ""
Else
  ftpPath = "/import/photos/"
End If
Do Until rs.EOF
TryAgain:
  If Len(rs!SoftSlipPicPathFile
    If Dir(rs!SoftSlipPicPathFile
      If Me.cboLocation <> "SPCALA Webpage" Then
        Me.Bookmark = rs.Bookmark
      End If
      With objFTP
        '.SourceFile = imgPath & "\" & rs!SoftSlip & ".jpg"
        .SourceFile = rs!SoftSlipPicPathFile
        .DestinationFile = ftpPath & rs!SoftSlip & ".jpg"
        .UploadFileToFTPServer
      End With
      ' since the focus is now on the photos folder, we don't need the path any more
      'If Me.cboLocation <> "SPCALA Webpage" Then
        ftpPath = ""
      'End If
      Me!txtUploading = rs!SoftSlip
      Me!txtSent = Me!txtSent + 1
    Else
      Me!txtNoPic = Me!txtNoPic + 1
    End If
  Else
    Me!txtNoPic = Me!txtNoPic + 1
  End If
  Me!txtTotal = Me!txtTotal + 1
  Me.Repaint
  rs.MoveNext
Loop
PROC_EXIT:
  On Error Resume Next
  Set objFTP = Nothing
  Exit Sub
 Â
Proc_Error:
  Select Case Err.Number
    Case -2147219289 ' FTP switching to binary
      'MsgBox "FTP switching to binary, retrying " & rs!SoftSlip
      ErrCount = ErrCount + 1
      If ErrCount < 6 Then
        With objFTP
          If Me.cboLocation = "SPCALA Webpage" Then
            .FtpURL = conWEBPAGE
          Else
            .FtpURL = conTARGET
          End If
          .ConnectToFTPHost strAccount, strPassword
        End With
        Resume TryAgain
      Else
        ' msgbox commented out per JR's request
        'MsgBox "Too many FTP errors for " & rs!SoftSlip & ", skipping to next picture"
        rsFail.AddNew
          rsFail!SoftSlip = rs!SoftSlip
          rsFail!faildate = Now
        rsFail.Update
       Â
        ErrCount = 0
        rs.MoveNext
        If rs.EOF Then
          Resume PROC_EXIT
        Else
          Resume TryAgain
        End If
      End If
    Case Else
      MsgBox "Error " & Err.Number & " in cmdFTP_Click:" & vbCrLf & Err.Description
  End Select
  Resume PROC_EXIT
End Sub
Private Sub Form_Current()
' Update image for this animal
Dim strPath As String
Dim strFile As String
On Error Resume Next
strPath = DLookup("DefaultImagePath"
'strFile = strPath &Â "\" &Â Me!SoftSlip &Â ".jpg"
strFile = Nz(Me!SoftSlipPicPathFile,
If Dir(strFile) <>Â "" Then
  Me.imgAnimalPicture.Pictur
End If
End Sub
Private Sub cmdClose_Click()
On Error GoTo Err_cmdclose_Click
  DoCmd.close
Exit_cmdclose_Click:
  Exit Sub
Err_cmdclose_Click:
  MsgBox Err.Description
  Resume Exit_cmdclose_Click
 Â
End Sub
Sub FindingRoverExport(strTARG
  Dim strPath As String
  Dim strZip As String
  Dim strTxt As String
  Dim strTo As String
  Dim strTitle As String
  Dim strMsg As String
  Dim strSQL As String
  Dim rs As DAO.Recordset
  Dim rsHistory As DAO.Recordset
  Dim s As String
  Dim i As Integer
  Dim arrPic() As String
  Dim strRoverPicPath As String
  Dim strRoverPic As String
  Dim objFTP As FTP
 Â
  '*************  File paths **************************
  strRoverPicPath = "" & DLookup("Rover", "tblPaths")
  strPath = "C:\Paw Trax\FindingRoverFiles"
  strZip = "C:\Paw Trax\FindingRoverFiles\Fin
  strTxt = "C:\Paw Trax\FindingRoverFiles\Fin
  '*************************
 Â
  On Error Resume Next
  DoCmd.Hourglass True
  If Dir(strPath & "\") & "" = "" Then
    MkDir strPath
  Else
    Kill strZip
    Kill strTxt
   Â
  End If
  On Error GoTo PROC_ERR
 Â
  strSQL = "DELETE * FROM tblTEMPFindingRover"
  CurrentDb.Execute strSQL, dbFailOnError + dbSeeChanges
  Do Until DCount("*", "tblTEMPFindingRover") = 0
    DoEvents
  Loop
 Â
  If DCount("*", "qryFindingRoverUpdates") = 0 Then
    MsgBox "There are no new or updated records to send"
    GoTo PROC_EXIT
  End If
 Â
  'DoCmd.OpenReport "rptFindingRoverUpdates", acViewPreview
  '  Save report in PDF format, and open it for display
  DoCmd.OutputTo acOutputReport, "rptFindingRoverUpdates", acFormatPDF, strPath & "\" & Format(Now, "yyyymmddhhnnss") & "_FindingRover.pdf", True
  DoCmd.OpenQuery "qryupdFindingRoverExport"
  DoEvents
 Â
  strSQL = "SELECT SoftSlip, Pic, EncodedImage FROM tblTEMPFindingRover WHERE Pic & '' <> '' AND pic NOT LIKE '*NoImage*'"
  Set rs = CurrentDb.OpenRecordset(st
  Do Until rs.RecordCount = 0 Or rs.EOF
    'arrPic = Split(rs("Pic"), "\")
    arrPic = Split(rs("Pic"), "Pet-Ark\")
    strRoverPic = strRoverPicPath & arrPic(UBound(arrPic))
    s = Replace(Replace(ImageToBas
    If s <> "COULD NOT ENCODE SPECIFIED FILE" Then
      rs.Edit
      rs("EncodedImage") = s
      rs.Update
    End If
    rs.MoveNext
  Loop
 Â
 Â
  strPath = strPath & "\FindingRover"
 Â
  ' Export query to csv and put it in a zip file
  DoCmd.TransferText acExportDelim, "FindingRoverExport", "tblTEMPFindingRover", strTxt, True
  Zip strZip, strTxt
 Â
  ' ftp text file to finding rover
  ' strPath = PathName & "\" & strAccount & ".txt"
  DoCmd.TransferText acExportDelim, "FindingRoverExport", "tblTEMPFindingRover", strTxt, True
  Set objFTP = New FTP
  With objFTP
    .SourceFile = strTxt
    .FtpURL = strTARGET
    .DestinationFile = "/Shelters/LASPCAProd/" & Format(Now, "yyyymmddhhnnss") & "_FindingRover" & ".txt"
    .AutoCreateRemoteDir = False
    .ConnectToFTPHost strAccount, strPassword
    .UploadFileToFTPServer
  End With
  Â
  MsgBox "Data sent to Finding Rover"
  ' Attach Zip file to email
  ' 2015-10-22 -- replaced the email code with the above FTP code.
  'strTo = ""
  'strTitle = "Finding Rover Files"
  'strMsg = "See attached."
  'SendEmail strTo, strMsg, strTitle, strZip
 Â
 Â
 Â
  ' Update/Add changed or new records to history table
  strSQL = "SELECT * FROM qryFindingRoverUpdates"
  Set rs = CurrentDb.OpenRecordset(st
  Do Until rs.RecordCount = 0 Or rs.EOF
    strSQL = "SELECT * FROM tblFindingRoverHistory WHERE SoftSlip = '" & rs("SoftSlip") & "'"
    Set rsHistory = CurrentDb.OpenRecordset(st
    With rsHistory
      If .RecordCount = 0 Then .AddNew Else .Edit
      For i = 0 To (rs.Fields.Count - 1)
        .Fields(i) = rs.Fields(i)
      Next
      !DateSent = Now()
      .Update
    End With
    rsHistory.close
    Set rsHistory = Nothing
    rs.MoveNext
  Loop
 Â
 Â
PROC_EXIT:
  DoCmd.Hourglass False
 Â
 Â
  On Error Resume Next
  rs.close
  Set rs = Nothing
  strSQL = "DELETE * FROM tblTEMPFindingRover"
  CurrentDb.Execute strSQL, dbFailOnError + dbSeeChanges
 Â
  Exit Sub
PROC_ERR:
  If Err.Number = 2501 Then GoTo PROC_EXIT
  MsgBox "ERROR " & Err.Number & ": " & Err.Description
  GoTo PROC_EXIT
End Sub
Sub Activ4PetsExport(strDest As String)
  Dim strPath As String
  'Dim strZip As String
  Dim strTxt As String
  Dim strTo As String
  Dim strTitle As String
  Dim strMsg As String
  Dim strSQL As String
  Dim rs As DAO.Recordset
  Dim rsHistory As DAO.Recordset
  Dim i As Integer
 Â
  '*************  File paths Miriam **************************
  'strPath = "C:\Users\Surf\Documents\d
  'strZip = "C:\Users\Surf\Documents\d
  'strTxt = "C:\Users\Surf\Documents\d
  '*************************
 Â
  '*************  File paths Production **************************
  strPath = "C:\Paw Trax\FindingRoverFiles"
  'strZip = "C:\Paw Trax\FindingRoverFiles\act
  strTxt = "C:\Paw Trax\FindingRoverFiles\act
  '*************************
 Â
  On Error Resume Next
  DoCmd.Hourglass True
  If Dir(strPath & "\") & "" = "" Then
    MkDir strPath
  Else
    'Kill strZip
    Kill strTxt
   Â
  End If
  On Error GoTo PROC_ERR
 Â
  If DCount("*", "qryActiv4PetsUpdates") = 0 Then
    MsgBox "There are no new or updated records to send"
    GoTo PROC_EXIT
  End If
  'DoCmd.OpenReport "rptFindingRoverUpdates", acViewPreview
  '  Save report in PDF format, and open it for display
  'DoCmd.OutputTo acOutputReport, "activ4petsUpdates", acFormatPDF, strPath & "\" & Format(Now, "yyyymmddhhnnss") & "_FindingRover.pdf", True
  'DoCmd.OpenQuery "qryupdactiv4petsExport"
  'DoEvents
  ' strPath = strPath & "\FindingRover"
 Â
  ' Export query to csv and put it in a zip file
  'DoCmd.TransferText acExportDelim, "FindingRoverExport", "tblTEMPFindingRover", strTxt, True
  'Zip strZip, strTxt
 Â
  ' ftp text file to finding rover
  'strPath = PathName & "\" & strAccount & ".txt"
  'DoCmd.TransferText acExportDelim, "FindingRoverExport", "tblTEMPFindingRover", strTxt, True
  'Set objFTP = New FTP
  'With objFTP
  '   .SourceFile = strTxt
  '   .FtpURL = strTARGET
  '   .DestinationFile = "/Shelters/LASPCAProd/" & Format(Now, "yyyymmddhhnnss") & "_FindingRover" & ".txt"
  '   .AutoCreateRemoteDir = False
  '   .ConnectToFTPHost strAccount, strPassword
  '   .UploadFileToFTPServer
  'End With
  Â
  ExcelExport strTxt, "SoftSlip Info", "SELECT * FROM qryActiv4PetsToSend"
  ExcelExport strTxt, "Medical Procedures", "SELECT * FROM qryActiv4PetsProcedures"
  ExcelExport strTxt, "Medications And Vaccinations", "SELECT * FROM qryActiv4PetsMedications"
  ExcelExport strTxt, "Vet Notes", "SELECT * FROM qryActiv4PetsNotes"
 Â
  'MsgBox "Data sent to active4Pets"
  ' Attach Zip file to email
  ' 2015-10-22 -- replaced the email code with the above FTP code.
  'Zip strZip, strTxt
  strTitle = "SPCALA Paw Trax Export"
  strMsg = "See attached."
  SendEmail strDest, strMsg, strTitle, strTxt
 Â
 Â
  ' Update/Add changed or new records to history table
  strSQL = "SELECT * FROM qryActiv4PetsUpdates"
  Set rs = CurrentDb.OpenRecordset(st
  Do Until rs.RecordCount = 0 Or rs.EOF
    strSQL = "SELECT * FROM tblActiv4PetsHistory WHERE SoftSlip = '" & rs("SoftSlip") & "'"
    Set rsHistory = CurrentDb.OpenRecordset(st
    With rsHistory
      If .RecordCount = 0 Then .AddNew Else .Edit
      For i = 0 To (rs.Fields.Count - 1)
        .Fields(i) = rs.Fields(i)
      Next
      !DateSent = Now()
      .Update
    End With
    rsHistory.close
    Set rsHistory = Nothing
    rs.MoveNext
  Loop
 Â
 Â
PROC_EXIT:
  DoCmd.Hourglass False
  Exit Sub
 Â
  On Error Resume Next
PROC_ERR:
  If Err.Number = 2501 Then GoTo PROC_EXIT
  MsgBox "ERROR " & Err.Number & ": " & Err.Description
  GoTo PROC_EXIT
End Sub
1. Do you have DAO360.DLL under C:\Program Files (x86)\Common Files\microsoft shared\DAO\
and here?
C:\Windows\SysWOW64\
C:\Windows\System32\
and here?
C:\Windows\SysWOW64\
C:\Windows\System32\
ASKER
I've tried upload from Windows server 2012 R2 and Windows 7. Â I've also tried access 2013 and 2016.
The site is ftp://spcala.com
The site is ftp://spcala.com
ASKER
DAO360.dll is only in the microsoft folder
Okay, copy the DAO360.dll from "C:\Program Files (x86)\Common Files\microsoft shared\DAO\" to C:\Windows\SysWOW64\ Â and C:\Windows\System32\ if the folders exist and try the ftp again. And report back.
ASKER
copied files. Â Same error
ASKER
I also saw DAO350.dll in the Microsoft folder
Is it possible to reboot and try the FTP again?
ASKER
sure
Looking over your code I noticed that in (MsgBox "Error "Â & Err.Number &Â " in cmdFTP_Click:" &Â vbCrLf &Â Err.Description) the cmdFTP_Click is not declared anywhere. Has the code changed before the issue occurred?
ASKER
I rebooted my computer. Â Same error. Â Rebooting the server now would be very difficult, but if necessary I could do it.
To clarify the environment. Â The front and backends are stored on a 2012 R2 server. Â I've tried running the upload from the server and from my computer.
The server is using Access 2013. Â My computer is running Access 2016.
Just to clarify, it worked on Friday
To clarify the environment. Â The front and backends are stored on a 2012 R2 server. Â I've tried running the upload from the server and from my computer.
The server is using Access 2013. Â My computer is running Access 2016.
Just to clarify, it worked on Friday
Let's leave the server alone because you mentioned that you are able to connect to it using Filezilla .
Open the app, open the VBA editor, and do a compile.
 Do you compile with no errors?
Jim.
 Do you compile with no errors?
Jim.
ASKER
No the code hasn't changed. Â The only change is we went from 2013 to 2016. Â Here is the code from a version backed up 10/21/17
Option Compare Database
Option Explicit
Private Sub cboLocation_AfterUpdate()
Me.Requery
End Sub
Private Sub cmdFTP_Click()
Dim strAccount As String
Dim strPassword As String
Dim strDest As String
Const conRover = "ftp://ftp.storagemadeeasy.com"
Const conActiv4Pets = "spcala@activ4pets.com"
On Error GoTo Proc_Error
' initialize paths for different locations
Select Case Me.cboLocation
  Case "Long Beach"
    strAccount = "CA366"
    strPassword = "4"
    SPCALAExport strAccount, strPassword
    Exit Sub
   Â
  Case "South Bay"
    strAccount = "CA1612"
    strPassword = "etz"
    SPCALAExport strAccount, strPassword
    Exit Sub
   Â
  Case "Pico Rivera"  ' Pico credentials.  Note that if the account is  Ca2356, the text file uploaded should be named Ca2353.txt (it should match the account) **********
    strAccount = "CA2356"
    strPassword = "m"
    SPCALAExport strAccount, strPassword
    Exit Sub
   Â
  Case "SPCALA Webpage"
    strAccount = "pawtrax2@spcala.com"
    strPassword = "2!@"
    SPCALAExport strAccount, strPassword
    Exit Sub
   Â
  Case "Finding Rover"
    strAccount = "laspca@findingrover"
    strPassword = "ndingR0ver"
    FindingRoverExport conRover, strAccount, strPassword
    Exit Sub
   Â
  Case "activ4pets"
    strDest = conActiv4Pets
    Activ4PetsExport (strDest)
    Exit Sub
 Â
  Case Else
    MsgBox "Please select Long Beach or South Bay as location, or select SPCALA Webpage"
    Exit Sub
End Select
PROC_EXIT:
  On Error Resume Next
  Exit Sub
 Â
Proc_Error:
  MsgBox "Error " & Err.Number & " in cmdFTP_Click:" & vbCrLf & Err.Description
  Resume PROC_EXIT
End Sub
Sub InitFTPObject(objFTP As FTP, strPath As String, strPage As String, strDest As String, strAccount As String, strPassword As String)
    With objFTP
      .SourceFile = strPath
      .FtpURL = strPage
      .DestinationFile = strDest
      .AutoCreateRemoteDir = False
      .ConnectToFTPHost strAccount, strPassword
      .UploadFileToFTPServer
    End With
End Sub
Private Sub SPCALAExport(strAccount As String, strPassword As String)
Dim objFTP As FTP
Dim strPath As String
Dim imgPath As String
Dim ftpPath As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rsFail As DAO.Recordset
Dim ErrCount As Integer
Const conTARGET = "ftp://members.petfinder.com"
Const conRover = "ftp://ftp.storagemadeeasy.com"
Const conWEBPAGE = "ftp://spcala.com"
Const PathName = "\\databases\access2015\Pe tfinder"
On Error GoTo Proc_Error
' initialize progress tracking textboxes
Me!txtAvailable = Me.RecordsetClone.RecordCo unt
If Me.cboLocation = "SPCALA Webpage" Then
  Me!txtAvailable = DCount("*", "qryWebpageExport")
End If
Me!txtSent = 0
Me!txtNoPic = 0
Me!txtTotal = 0
ErrCount = 0
' export the query
If Me.cboLocation = "SPCALA Webpage" Then
  strPath = PathName & "\adoptable.txt"
  'Application.ExportXML ObjectType:=acExportQuery, _
  'DataSource:="qryWebpageEx port", _
  'datatarget:=strPath
  DoCmd.TransferText acExportDelim, "Webpage Export Specification", _
   "qryWebpageExport", strPath, True
  Set objFTP = New FTP
  With objFTP
    .SourceFile = strPath
    .FtpURL = conWEBPAGE
    .DestinationFile = "adoptable.txt"
    .AutoCreateRemoteDir = False
    .ConnectToFTPHost strAccount, strPassword
    .UploadFileToFTPServer
  End With
Else
  strPath = PathName & "\" & strAccount & ".txt"
  DoCmd.TransferText acExportDelim, "Petfinder Export Specification", "qryPetfinderExport", strPath, True
  Set objFTP = New FTP
  With objFTP
    .SourceFile = strPath
    .FtpURL = conTARGET
    .DestinationFile = "/import/" & strAccount & ".txt"
    .AutoCreateRemoteDir = False
    .ConnectToFTPHost strAccount, strPassword
    .UploadFileToFTPServer
  End With
End If
'export all pictures
imgPath = DLookup("DefaultImagePath" , "tbl_ImageDefaultPath", "ImageType='SoftSlips'")
Set db = CurrentDb
Set rsFail = db.OpenRecordset("tblPetfi nderFailur es", dbOpenDynaset)
If Me.cboLocation = "SPCALA Webpage" Then
  Set rs = db.OpenRecordset("qryWebpa geExport", dbOpenDynaset)
Else
  Set rs = Me.RecordsetClone
End If
rs.MoveFirst
With objFTP
  If Me.cboLocation = "SPCALA Webpage" Then
    .FtpURL = conWEBPAGE
  Else
    .FtpURL = conTARGET
  End If
  .ConnectToFTPHost strAccount, strPassword
End With
' set initial ftp
If Me.cboLocation = "SPCALA Webpage" Then
  ftpPath = ""
Else
  ftpPath = "/import/photos/"
End If
Do Until rs.EOF
TryAgain:
  If Len(rs!SoftSlipPicPathFile & "") <> 0 Then
    If Dir(rs!SoftSlipPicPathFile ) <> "" Then
      If Me.cboLocation <> "SPCALA Webpage" Then
        Me.Bookmark = rs.Bookmark
      End If
      With objFTP
        '.SourceFile = imgPath & "\" & rs!SoftSlip & ".jpg"
        .SourceFile = rs!SoftSlipPicPathFile
        .DestinationFile = ftpPath & rs!SoftSlip & ".jpg"
        .UploadFileToFTPServer
      End With
      ' since the focus is now on the photos folder, we don't need the path any more
      'If Me.cboLocation <> "SPCALA Webpage" Then
        ftpPath = ""
      'End If
      Me!txtUploading = rs!SoftSlip
      Me!txtSent = Me!txtSent + 1
    Else
      Me!txtNoPic = Me!txtNoPic + 1
    End If
  Else
    Me!txtNoPic = Me!txtNoPic + 1
  End If
  Me!txtTotal = Me!txtTotal + 1
  Me.Repaint
  rs.MoveNext
Loop
PROC_EXIT:
  On Error Resume Next
  Set objFTP = Nothing
  Exit Sub
 Â
Proc_Error:
  Select Case Err.Number
    Case -2147219289 ' FTP switching to binary
      'MsgBox "FTP switching to binary, retrying " & rs!SoftSlip
      ErrCount = ErrCount + 1
      If ErrCount < 6 Then
        With objFTP
          If Me.cboLocation = "SPCALA Webpage" Then
            .FtpURL = conWEBPAGE
          Else
            .FtpURL = conTARGET
          End If
          .ConnectToFTPHost strAccount, strPassword
        End With
        Resume TryAgain
      Else
        ' msgbox commented out per JR's request
        'MsgBox "Too many FTP errors for " & rs!SoftSlip & ", skipping to next picture"
        rsFail.AddNew
          rsFail!SoftSlip = rs!SoftSlip
          rsFail!faildate = Now
        rsFail.Update
       Â
        ErrCount = 0
        rs.MoveNext
        If rs.EOF Then
          Resume PROC_EXIT
        Else
          Resume TryAgain
        End If
      End If
    Case Else
      MsgBox "Error " & Err.Number & " in cmdFTP_Click:" & vbCrLf & Err.Description
  End Select
  Resume PROC_EXIT
End Sub
Private Sub Form_Current()
' Update image for this animal
Dim strPath As String
Dim strFile As String
On Error Resume Next
strPath = DLookup("DefaultImagePath" , "tbl_ImageDefaultPath", "ImageType='SoftSlips'")
'strFile = strPath &Â "\" &Â Me!SoftSlip &Â ".jpg"
strFile = Nz(Me!SoftSlipPicPathFile, strPath &Â "\NoPicture.jpg")
If Dir(strFile) <>Â "" Then
  Me.imgAnimalPicture.Pictur e = strFile
End If
End Sub
Private Sub cmdClose_Click()
On Error GoTo Err_cmdclose_Click
  DoCmd.Close
Exit_cmdclose_Click:
  Exit Sub
Err_cmdclose_Click:
  MsgBox Err.Description
  Resume Exit_cmdclose_Click
 Â
End Sub
Sub FindingRoverExport(strTARG ET As String, strAccount As String, strPassword As String)
  Dim strPath As String
  Dim strZip As String
  Dim strTxt As String
  Dim strTo As String
  Dim strTitle As String
  Dim strMsg As String
  Dim strSQL As String
  Dim rs As DAO.Recordset
  Dim rsHistory As DAO.Recordset
  Dim s As String
  Dim i As Integer
  Dim arrPic() As String
  Dim strRoverPicPath As String
  Dim strRoverPic As String
  Dim objFTP As FTP
 Â
  '*************  File paths **************************
  strRoverPicPath = "" & DLookup("Rover", "tblPaths")
  strPath = "C:\Paw Trax\FindingRoverFiles"
  strZip = "C:\Paw Trax\FindingRoverFiles\Fin dingRover. zip"
  strTxt = "C:\Paw Trax\FindingRoverFiles\Fin dingRover. txt"
  '************************* ********** ********** *********
 Â
  On Error Resume Next
  DoCmd.Hourglass True
  If Dir(strPath & "\") & "" = "" Then
    MkDir strPath
  Else
    Kill strZip
    Kill strTxt
   Â
  End If
  On Error GoTo PROC_ERR
 Â
  strSQL = "DELETE * FROM tblTEMPFindingRover"
  CurrentDb.Execute strSQL, dbFailOnError + dbSeeChanges
  Do Until DCount("*", "tblTEMPFindingRover") = 0
    DoEvents
  Loop
 Â
  If DCount("*", "qryFindingRoverUpdates") = 0 Then
    MsgBox "There are no new or updated records to send"
    GoTo PROC_EXIT
  End If
 Â
  'DoCmd.OpenReport "rptFindingRoverUpdates", acViewPreview
  '  Save report in PDF format, and open it for display
  DoCmd.OutputTo acOutputReport, "rptFindingRoverUpdates", acFormatPDF, strPath & "\" & Format(Now, "yyyymmddhhnnss") & "_FindingRover.pdf", True
  DoCmd.OpenQuery "qryupdFindingRoverExport"
  DoEvents
 Â
  strSQL = "SELECT SoftSlip, Pic, EncodedImage FROM tblTEMPFindingRover WHERE Pic & '' <> '' AND pic NOT LIKE '*NoImage*'"
  Set rs = CurrentDb.OpenRecordset(st rSQL, dbOpenDynaset, dbSeeChanges)
  Do Until rs.RecordCount = 0 Or rs.EOF
    'arrPic = Split(rs("Pic"), "\")
    arrPic = Split(rs("Pic"), "Pet-Ark\")
    strRoverPic = strRoverPicPath & arrPic(UBound(arrPic))
    s = Replace(Replace(ImageToBas e64Encoded (strRoverP ic), Chr(10), ""), Chr(13), "")
    If s <> "COULD NOT ENCODE SPECIFIED FILE" Then
      rs.Edit
      rs("EncodedImage") = s
      rs.Update
    End If
    rs.MoveNext
  Loop
 Â
 Â
  strPath = strPath & "\FindingRover"
 Â
  ' Export query to csv and put it in a zip file
  DoCmd.TransferText acExportDelim, "FindingRoverExport", "tblTEMPFindingRover", strTxt, True
  Zip strZip, strTxt
 Â
  ' ftp text file to finding rover
  ' strPath = PathName & "\" & strAccount & ".txt"
  DoCmd.TransferText acExportDelim, "FindingRoverExport", "tblTEMPFindingRover", strTxt, True
  Set objFTP = New FTP
  With objFTP
    .SourceFile = strTxt
    .FtpURL = strTARGET
    .DestinationFile = "/Shelters/LASPCAProd/" & Format(Now, "yyyymmddhhnnss") & "_FindingRover" & ".txt"
    .AutoCreateRemoteDir = False
    .ConnectToFTPHost strAccount, strPassword
    .UploadFileToFTPServer
  End With
  Â
  MsgBox "Data sent to Finding Rover"
  ' Attach Zip file to email
  ' 2015-10-22 -- replaced the email code with the above FTP code.
  'strTo = ""
  'strTitle = "Finding Rover Files"
  'strMsg = "See attached."
  'SendEmail strTo, strMsg, strTitle, strZip
 Â
 Â
 Â
  ' Update/Add changed or new records to history table
  strSQL = "SELECT * FROM qryFindingRoverUpdates"
  Set rs = CurrentDb.OpenRecordset(st rSQL, dbOpenDynaset, dbSeeChanges)
  Do Until rs.RecordCount = 0 Or rs.EOF
    strSQL = "SELECT * FROM tblFindingRoverHistory WHERE SoftSlip = '" & rs("SoftSlip") & "'"
    Set rsHistory = CurrentDb.OpenRecordset(st rSQL, dbOpenDynaset, dbSeeChanges)
    With rsHistory
      If .RecordCount = 0 Then .AddNew Else .Edit
      For i = 0 To (rs.Fields.Count - 1)
        .Fields(i) = rs.Fields(i)
      Next
      !DateSent = Now()
      .Update
    End With
    rsHistory.Close
    Set rsHistory = Nothing
    rs.MoveNext
  Loop
 Â
 Â
PROC_EXIT:
  DoCmd.Hourglass False
 Â
 Â
  On Error Resume Next
  rs.Close
  Set rs = Nothing
  strSQL = "DELETE * FROM tblTEMPFindingRover"
  CurrentDb.Execute strSQL, dbFailOnError + dbSeeChanges
 Â
  Exit Sub
PROC_ERR:
  If Err.Number = 2501 Then GoTo PROC_EXIT
  MsgBox "ERROR " & Err.Number & ": " & Err.Description
  GoTo PROC_EXIT
End Sub
Sub Activ4PetsExport(strDest As String)
  Dim strPath As String
  'Dim strZip As String
  Dim strTxt As String
  Dim strTo As String
  Dim strTitle As String
  Dim strMsg As String
  Dim strSQL As String
  Dim rs As DAO.Recordset
  Dim rsHistory As DAO.Recordset
  Dim i As Integer
 Â
  '*************  File paths Miriam **************************
  'strPath = "C:\Users\Surf\Documents\d bApps\PawT rax\Findin gRoverFile s"
  'strZip = "C:\Users\Surf\Documents\d bApps\PawT rax\Findin gRoverFile s\activ4pe ts.zip"
  'strTxt = "C:\Users\Surf\Documents\d bApps\PawT rax\Findin gRoverFile s\activ4pe ts.xlsx"
  '************************* ********** ********** *********
 Â
  '*************  File paths Production **************************
  strPath = "C:\Paw Trax\FindingRoverFiles"
  'strZip = "C:\Paw Trax\FindingRoverFiles\act iv4pets.zi p"
  strTxt = "C:\Paw Trax\FindingRoverFiles\act iv4pets.xl sx"
  '************************* ********** ********** *********
 Â
  On Error Resume Next
  DoCmd.Hourglass True
  If Dir(strPath & "\") & "" = "" Then
    MkDir strPath
  Else
    'Kill strZip
    Kill strTxt
   Â
  End If
  On Error GoTo PROC_ERR
 Â
  If DCount("*", "qryActiv4PetsUpdates") = 0 Then
    MsgBox "There are no new or updated records to send"
    GoTo PROC_EXIT
  End If
  'DoCmd.OpenReport "rptFindingRoverUpdates", acViewPreview
  '  Save report in PDF format, and open it for display
  'DoCmd.OutputTo acOutputReport, "activ4petsUpdates", acFormatPDF, strPath & "\" & Format(Now, "yyyymmddhhnnss") & "_FindingRover.pdf", True
  'DoCmd.OpenQuery "qryupdactiv4petsExport"
  'DoEvents
  ' strPath = strPath & "\FindingRover"
 Â
  ' Export query to csv and put it in a zip file
  'DoCmd.TransferText acExportDelim, "FindingRoverExport", "tblTEMPFindingRover", strTxt, True
  'Zip strZip, strTxt
 Â
  ' ftp text file to finding rover
  'strPath = PathName & "\" & strAccount & ".txt"
  'DoCmd.TransferText acExportDelim, "FindingRoverExport", "tblTEMPFindingRover", strTxt, True
  'Set objFTP = New FTP
  'With objFTP
  '   .SourceFile = strTxt
  '   .FtpURL = strTARGET
  '   .DestinationFile = "/Shelters/LASPCAProd/" & Format(Now, "yyyymmddhhnnss") & "_FindingRover" & ".txt"
  '   .AutoCreateRemoteDir = False
  '   .ConnectToFTPHost strAccount, strPassword
  '   .UploadFileToFTPServer
  'End With
  Â
  ExcelExport strTxt, "SoftSlip Info", "SELECT * FROM qryActiv4PetsToSend"
  ExcelExport strTxt, "Medical Procedures", "SELECT * FROM qryActiv4PetsProcedures"
  ExcelExport strTxt, "Medications And Vaccinations", "SELECT * FROM qryActiv4PetsMedications"
  ExcelExport strTxt, "Vet Notes", "SELECT * FROM qryActiv4PetsNotes"
 Â
  'MsgBox "Data sent to active4Pets"
  ' Attach Zip file to email
  ' 2015-10-22 -- replaced the email code with the above FTP code.
  'Zip strZip, strTxt
  strTitle = "SPCALA Paw Trax Export"
  strMsg = "See attached."
  SendEmail strDest, strMsg, strTitle, strTxt
 Â
 Â
  ' Update/Add changed or new records to history table
  strSQL = "SELECT * FROM qryActiv4PetsUpdates"
  Set rs = CurrentDb.OpenRecordset(st rSQL, dbOpenDynaset, dbSeeChanges)
  Do Until rs.RecordCount = 0 Or rs.EOF
    strSQL = "SELECT * FROM tblActiv4PetsHistory WHERE SoftSlip = '" & rs("SoftSlip") & "'"
    Set rsHistory = CurrentDb.OpenRecordset(st rSQL, dbOpenDynaset, dbSeeChanges)
    With rsHistory
      If .RecordCount = 0 Then .AddNew Else .Edit
      For i = 0 To (rs.Fields.Count - 1)
        .Fields(i) = rs.Fields(i)
      Next
      !DateSent = Now()
      .Update
    End With
    rsHistory.Close
    Set rsHistory = Nothing
    rs.MoveNext
  Loop
 Â
 Â
PROC_EXIT:
  DoCmd.Hourglass False
  Exit Sub
 Â
  On Error Resume Next
PROC_ERR:
  If Err.Number = 2501 Then GoTo PROC_EXIT
  MsgBox "ERROR " & Err.Number & ": " & Err.Description
  GoTo PROC_EXIT
End Sub
Option Compare Database
Option Explicit
Private Sub cboLocation_AfterUpdate()
Me.Requery
End Sub
Private Sub cmdFTP_Click()
Dim strAccount As String
Dim strPassword As String
Dim strDest As String
Const conRover = "ftp://ftp.storagemadeeasy.com"
Const conActiv4Pets = "spcala@activ4pets.com"
On Error GoTo Proc_Error
' initialize paths for different locations
Select Case Me.cboLocation
  Case "Long Beach"
    strAccount = "CA366"
    strPassword = "4"
    SPCALAExport strAccount, strPassword
    Exit Sub
   Â
  Case "South Bay"
    strAccount = "CA1612"
    strPassword = "etz"
    SPCALAExport strAccount, strPassword
    Exit Sub
   Â
  Case "Pico Rivera"  ' Pico credentials.  Note that if the account is  Ca2356, the text file uploaded should be named Ca2353.txt (it should match the account) **********
    strAccount = "CA2356"
    strPassword = "m"
    SPCALAExport strAccount, strPassword
    Exit Sub
   Â
  Case "SPCALA Webpage"
    strAccount = "pawtrax2@spcala.com"
    strPassword = "2!@"
    SPCALAExport strAccount, strPassword
    Exit Sub
   Â
  Case "Finding Rover"
    strAccount = "laspca@findingrover"
    strPassword = "ndingR0ver"
    FindingRoverExport conRover, strAccount, strPassword
    Exit Sub
   Â
  Case "activ4pets"
    strDest = conActiv4Pets
    Activ4PetsExport (strDest)
    Exit Sub
 Â
  Case Else
    MsgBox "Please select Long Beach or South Bay as location, or select SPCALA Webpage"
    Exit Sub
End Select
PROC_EXIT:
  On Error Resume Next
  Exit Sub
 Â
Proc_Error:
  MsgBox "Error " & Err.Number & " in cmdFTP_Click:" & vbCrLf & Err.Description
  Resume PROC_EXIT
End Sub
Sub InitFTPObject(objFTP As FTP, strPath As String, strPage As String, strDest As String, strAccount As String, strPassword As String)
    With objFTP
      .SourceFile = strPath
      .FtpURL = strPage
      .DestinationFile = strDest
      .AutoCreateRemoteDir = False
      .ConnectToFTPHost strAccount, strPassword
      .UploadFileToFTPServer
    End With
End Sub
Private Sub SPCALAExport(strAccount As String, strPassword As String)
Dim objFTP As FTP
Dim strPath As String
Dim imgPath As String
Dim ftpPath As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rsFail As DAO.Recordset
Dim ErrCount As Integer
Const conTARGET = "ftp://members.petfinder.com"
Const conRover = "ftp://ftp.storagemadeeasy.com"
Const conWEBPAGE = "ftp://spcala.com"
Const PathName = "\\databases\access2015\Pe
On Error GoTo Proc_Error
' initialize progress tracking textboxes
Me!txtAvailable = Me.RecordsetClone.RecordCo
If Me.cboLocation = "SPCALA Webpage" Then
  Me!txtAvailable = DCount("*", "qryWebpageExport")
End If
Me!txtSent = 0
Me!txtNoPic = 0
Me!txtTotal = 0
ErrCount = 0
' export the query
If Me.cboLocation = "SPCALA Webpage" Then
  strPath = PathName & "\adoptable.txt"
  'Application.ExportXML ObjectType:=acExportQuery,
  'DataSource:="qryWebpageEx
  'datatarget:=strPath
  DoCmd.TransferText acExportDelim, "Webpage Export Specification", _
   "qryWebpageExport", strPath, True
  Set objFTP = New FTP
  With objFTP
    .SourceFile = strPath
    .FtpURL = conWEBPAGE
    .DestinationFile = "adoptable.txt"
    .AutoCreateRemoteDir = False
    .ConnectToFTPHost strAccount, strPassword
    .UploadFileToFTPServer
  End With
Else
  strPath = PathName & "\" & strAccount & ".txt"
  DoCmd.TransferText acExportDelim, "Petfinder Export Specification", "qryPetfinderExport", strPath, True
  Set objFTP = New FTP
  With objFTP
    .SourceFile = strPath
    .FtpURL = conTARGET
    .DestinationFile = "/import/" & strAccount & ".txt"
    .AutoCreateRemoteDir = False
    .ConnectToFTPHost strAccount, strPassword
    .UploadFileToFTPServer
  End With
End If
'export all pictures
imgPath = DLookup("DefaultImagePath"
Set db = CurrentDb
Set rsFail = db.OpenRecordset("tblPetfi
If Me.cboLocation = "SPCALA Webpage" Then
  Set rs = db.OpenRecordset("qryWebpa
Else
  Set rs = Me.RecordsetClone
End If
rs.MoveFirst
With objFTP
  If Me.cboLocation = "SPCALA Webpage" Then
    .FtpURL = conWEBPAGE
  Else
    .FtpURL = conTARGET
  End If
  .ConnectToFTPHost strAccount, strPassword
End With
' set initial ftp
If Me.cboLocation = "SPCALA Webpage" Then
  ftpPath = ""
Else
  ftpPath = "/import/photos/"
End If
Do Until rs.EOF
TryAgain:
  If Len(rs!SoftSlipPicPathFile
    If Dir(rs!SoftSlipPicPathFile
      If Me.cboLocation <> "SPCALA Webpage" Then
        Me.Bookmark = rs.Bookmark
      End If
      With objFTP
        '.SourceFile = imgPath & "\" & rs!SoftSlip & ".jpg"
        .SourceFile = rs!SoftSlipPicPathFile
        .DestinationFile = ftpPath & rs!SoftSlip & ".jpg"
        .UploadFileToFTPServer
      End With
      ' since the focus is now on the photos folder, we don't need the path any more
      'If Me.cboLocation <> "SPCALA Webpage" Then
        ftpPath = ""
      'End If
      Me!txtUploading = rs!SoftSlip
      Me!txtSent = Me!txtSent + 1
    Else
      Me!txtNoPic = Me!txtNoPic + 1
    End If
  Else
    Me!txtNoPic = Me!txtNoPic + 1
  End If
  Me!txtTotal = Me!txtTotal + 1
  Me.Repaint
  rs.MoveNext
Loop
PROC_EXIT:
  On Error Resume Next
  Set objFTP = Nothing
  Exit Sub
 Â
Proc_Error:
  Select Case Err.Number
    Case -2147219289 ' FTP switching to binary
      'MsgBox "FTP switching to binary, retrying " & rs!SoftSlip
      ErrCount = ErrCount + 1
      If ErrCount < 6 Then
        With objFTP
          If Me.cboLocation = "SPCALA Webpage" Then
            .FtpURL = conWEBPAGE
          Else
            .FtpURL = conTARGET
          End If
          .ConnectToFTPHost strAccount, strPassword
        End With
        Resume TryAgain
      Else
        ' msgbox commented out per JR's request
        'MsgBox "Too many FTP errors for " & rs!SoftSlip & ", skipping to next picture"
        rsFail.AddNew
          rsFail!SoftSlip = rs!SoftSlip
          rsFail!faildate = Now
        rsFail.Update
       Â
        ErrCount = 0
        rs.MoveNext
        If rs.EOF Then
          Resume PROC_EXIT
        Else
          Resume TryAgain
        End If
      End If
    Case Else
      MsgBox "Error " & Err.Number & " in cmdFTP_Click:" & vbCrLf & Err.Description
  End Select
  Resume PROC_EXIT
End Sub
Private Sub Form_Current()
' Update image for this animal
Dim strPath As String
Dim strFile As String
On Error Resume Next
strPath = DLookup("DefaultImagePath"
'strFile = strPath &Â "\" &Â Me!SoftSlip &Â ".jpg"
strFile = Nz(Me!SoftSlipPicPathFile,
If Dir(strFile) <>Â "" Then
  Me.imgAnimalPicture.Pictur
End If
End Sub
Private Sub cmdClose_Click()
On Error GoTo Err_cmdclose_Click
  DoCmd.Close
Exit_cmdclose_Click:
  Exit Sub
Err_cmdclose_Click:
  MsgBox Err.Description
  Resume Exit_cmdclose_Click
 Â
End Sub
Sub FindingRoverExport(strTARG
  Dim strPath As String
  Dim strZip As String
  Dim strTxt As String
  Dim strTo As String
  Dim strTitle As String
  Dim strMsg As String
  Dim strSQL As String
  Dim rs As DAO.Recordset
  Dim rsHistory As DAO.Recordset
  Dim s As String
  Dim i As Integer
  Dim arrPic() As String
  Dim strRoverPicPath As String
  Dim strRoverPic As String
  Dim objFTP As FTP
 Â
  '*************  File paths **************************
  strRoverPicPath = "" & DLookup("Rover", "tblPaths")
  strPath = "C:\Paw Trax\FindingRoverFiles"
  strZip = "C:\Paw Trax\FindingRoverFiles\Fin
  strTxt = "C:\Paw Trax\FindingRoverFiles\Fin
  '*************************
 Â
  On Error Resume Next
  DoCmd.Hourglass True
  If Dir(strPath & "\") & "" = "" Then
    MkDir strPath
  Else
    Kill strZip
    Kill strTxt
   Â
  End If
  On Error GoTo PROC_ERR
 Â
  strSQL = "DELETE * FROM tblTEMPFindingRover"
  CurrentDb.Execute strSQL, dbFailOnError + dbSeeChanges
  Do Until DCount("*", "tblTEMPFindingRover") = 0
    DoEvents
  Loop
 Â
  If DCount("*", "qryFindingRoverUpdates") = 0 Then
    MsgBox "There are no new or updated records to send"
    GoTo PROC_EXIT
  End If
 Â
  'DoCmd.OpenReport "rptFindingRoverUpdates", acViewPreview
  '  Save report in PDF format, and open it for display
  DoCmd.OutputTo acOutputReport, "rptFindingRoverUpdates", acFormatPDF, strPath & "\" & Format(Now, "yyyymmddhhnnss") & "_FindingRover.pdf", True
  DoCmd.OpenQuery "qryupdFindingRoverExport"
  DoEvents
 Â
  strSQL = "SELECT SoftSlip, Pic, EncodedImage FROM tblTEMPFindingRover WHERE Pic & '' <> '' AND pic NOT LIKE '*NoImage*'"
  Set rs = CurrentDb.OpenRecordset(st
  Do Until rs.RecordCount = 0 Or rs.EOF
    'arrPic = Split(rs("Pic"), "\")
    arrPic = Split(rs("Pic"), "Pet-Ark\")
    strRoverPic = strRoverPicPath & arrPic(UBound(arrPic))
    s = Replace(Replace(ImageToBas
    If s <> "COULD NOT ENCODE SPECIFIED FILE" Then
      rs.Edit
      rs("EncodedImage") = s
      rs.Update
    End If
    rs.MoveNext
  Loop
 Â
 Â
  strPath = strPath & "\FindingRover"
 Â
  ' Export query to csv and put it in a zip file
  DoCmd.TransferText acExportDelim, "FindingRoverExport", "tblTEMPFindingRover", strTxt, True
  Zip strZip, strTxt
 Â
  ' ftp text file to finding rover
  ' strPath = PathName & "\" & strAccount & ".txt"
  DoCmd.TransferText acExportDelim, "FindingRoverExport", "tblTEMPFindingRover", strTxt, True
  Set objFTP = New FTP
  With objFTP
    .SourceFile = strTxt
    .FtpURL = strTARGET
    .DestinationFile = "/Shelters/LASPCAProd/" & Format(Now, "yyyymmddhhnnss") & "_FindingRover" & ".txt"
    .AutoCreateRemoteDir = False
    .ConnectToFTPHost strAccount, strPassword
    .UploadFileToFTPServer
  End With
  Â
  MsgBox "Data sent to Finding Rover"
  ' Attach Zip file to email
  ' 2015-10-22 -- replaced the email code with the above FTP code.
  'strTo = ""
  'strTitle = "Finding Rover Files"
  'strMsg = "See attached."
  'SendEmail strTo, strMsg, strTitle, strZip
 Â
 Â
 Â
  ' Update/Add changed or new records to history table
  strSQL = "SELECT * FROM qryFindingRoverUpdates"
  Set rs = CurrentDb.OpenRecordset(st
  Do Until rs.RecordCount = 0 Or rs.EOF
    strSQL = "SELECT * FROM tblFindingRoverHistory WHERE SoftSlip = '" & rs("SoftSlip") & "'"
    Set rsHistory = CurrentDb.OpenRecordset(st
    With rsHistory
      If .RecordCount = 0 Then .AddNew Else .Edit
      For i = 0 To (rs.Fields.Count - 1)
        .Fields(i) = rs.Fields(i)
      Next
      !DateSent = Now()
      .Update
    End With
    rsHistory.Close
    Set rsHistory = Nothing
    rs.MoveNext
  Loop
 Â
 Â
PROC_EXIT:
  DoCmd.Hourglass False
 Â
 Â
  On Error Resume Next
  rs.Close
  Set rs = Nothing
  strSQL = "DELETE * FROM tblTEMPFindingRover"
  CurrentDb.Execute strSQL, dbFailOnError + dbSeeChanges
 Â
  Exit Sub
PROC_ERR:
  If Err.Number = 2501 Then GoTo PROC_EXIT
  MsgBox "ERROR " & Err.Number & ": " & Err.Description
  GoTo PROC_EXIT
End Sub
Sub Activ4PetsExport(strDest As String)
  Dim strPath As String
  'Dim strZip As String
  Dim strTxt As String
  Dim strTo As String
  Dim strTitle As String
  Dim strMsg As String
  Dim strSQL As String
  Dim rs As DAO.Recordset
  Dim rsHistory As DAO.Recordset
  Dim i As Integer
 Â
  '*************  File paths Miriam **************************
  'strPath = "C:\Users\Surf\Documents\d
  'strZip = "C:\Users\Surf\Documents\d
  'strTxt = "C:\Users\Surf\Documents\d
  '*************************
 Â
  '*************  File paths Production **************************
  strPath = "C:\Paw Trax\FindingRoverFiles"
  'strZip = "C:\Paw Trax\FindingRoverFiles\act
  strTxt = "C:\Paw Trax\FindingRoverFiles\act
  '*************************
 Â
  On Error Resume Next
  DoCmd.Hourglass True
  If Dir(strPath & "\") & "" = "" Then
    MkDir strPath
  Else
    'Kill strZip
    Kill strTxt
   Â
  End If
  On Error GoTo PROC_ERR
 Â
  If DCount("*", "qryActiv4PetsUpdates") = 0 Then
    MsgBox "There are no new or updated records to send"
    GoTo PROC_EXIT
  End If
  'DoCmd.OpenReport "rptFindingRoverUpdates", acViewPreview
  '  Save report in PDF format, and open it for display
  'DoCmd.OutputTo acOutputReport, "activ4petsUpdates", acFormatPDF, strPath & "\" & Format(Now, "yyyymmddhhnnss") & "_FindingRover.pdf", True
  'DoCmd.OpenQuery "qryupdactiv4petsExport"
  'DoEvents
  ' strPath = strPath & "\FindingRover"
 Â
  ' Export query to csv and put it in a zip file
  'DoCmd.TransferText acExportDelim, "FindingRoverExport", "tblTEMPFindingRover", strTxt, True
  'Zip strZip, strTxt
 Â
  ' ftp text file to finding rover
  'strPath = PathName & "\" & strAccount & ".txt"
  'DoCmd.TransferText acExportDelim, "FindingRoverExport", "tblTEMPFindingRover", strTxt, True
  'Set objFTP = New FTP
  'With objFTP
  '   .SourceFile = strTxt
  '   .FtpURL = strTARGET
  '   .DestinationFile = "/Shelters/LASPCAProd/" & Format(Now, "yyyymmddhhnnss") & "_FindingRover" & ".txt"
  '   .AutoCreateRemoteDir = False
  '   .ConnectToFTPHost strAccount, strPassword
  '   .UploadFileToFTPServer
  'End With
  Â
  ExcelExport strTxt, "SoftSlip Info", "SELECT * FROM qryActiv4PetsToSend"
  ExcelExport strTxt, "Medical Procedures", "SELECT * FROM qryActiv4PetsProcedures"
  ExcelExport strTxt, "Medications And Vaccinations", "SELECT * FROM qryActiv4PetsMedications"
  ExcelExport strTxt, "Vet Notes", "SELECT * FROM qryActiv4PetsNotes"
 Â
  'MsgBox "Data sent to active4Pets"
  ' Attach Zip file to email
  ' 2015-10-22 -- replaced the email code with the above FTP code.
  'Zip strZip, strTxt
  strTitle = "SPCALA Paw Trax Export"
  strMsg = "See attached."
  SendEmail strDest, strMsg, strTitle, strTxt
 Â
 Â
  ' Update/Add changed or new records to history table
  strSQL = "SELECT * FROM qryActiv4PetsUpdates"
  Set rs = CurrentDb.OpenRecordset(st
  Do Until rs.RecordCount = 0 Or rs.EOF
    strSQL = "SELECT * FROM tblActiv4PetsHistory WHERE SoftSlip = '" & rs("SoftSlip") & "'"
    Set rsHistory = CurrentDb.OpenRecordset(st
    With rsHistory
      If .RecordCount = 0 Then .AddNew Else .Edit
      For i = 0 To (rs.Fields.Count - 1)
        .Fields(i) = rs.Fields(i)
      Next
      !DateSent = Now()
      .Update
    End With
    rsHistory.Close
    Set rsHistory = Nothing
    rs.MoveNext
  Loop
 Â
 Â
PROC_EXIT:
  DoCmd.Hourglass False
  Exit Sub
 Â
  On Error Resume Next
PROC_ERR:
  If Err.Number = 2501 Then GoTo PROC_EXIT
  MsgBox "ERROR " & Err.Number & ": " & Err.Description
  GoTo PROC_EXIT
End Sub
<<What could be causing this. Â >>
 At a guess, it's broken references, namely the FTP object your using.  But first see if you can compile without error.
Jim.
 At a guess, it's broken references, namely the FTP object your using.  But first see if you can compile without error.
Jim.
ASKER
Compiles with no errors
OK, open the code again and put a stop in here:
' initialize paths for different locations
STOP
Select Case Me.cboLocation
  Case "Long Beach"
of cmdFTPClick. Â Execute. Â Â When you hit the stop, start executing the code step by step using F8. Â Might take a while, but at some point you'll get to the point of the error.
It's difficult to pin down from looking at the code because not every procedure has error handling (which it should) in it.
The error refers to a piece of code that is trying to look at an object (a recordset or the FTP object) and that object is not a reference to anything
Jim.
' initialize paths for different locations
STOP
Select Case Me.cboLocation
  Case "Long Beach"
of cmdFTPClick. Â Execute. Â Â When you hit the stop, start executing the code step by step using F8. Â Might take a while, but at some point you'll get to the point of the error.
It's difficult to pin down from looking at the code because not every procedure has error handling (which it should) in it.
The error refers to a piece of code that is trying to look at an object (a recordset or the FTP object) and that object is not a reference to anything
Jim.
"No the code hasn't changed. Â The only change is we went from 2013 to 2016. Â Here is the code from a version backed up 10/21/17"
Like Jim mentioned some references have changed when you moved from 2013 to 2016. It seems to be the cmdFTP_Click which is holding up the script.
Like Jim mentioned some references have changed when you moved from 2013 to 2016. It seems to be the cmdFTP_Click which is holding up the script.
ASKER
Need more clarification. Â I put the Stop in. Â When I hit F8 nothing happens.
Private Sub cmdFTP_Click()
Dim strAccount As String
Dim strPassword As String
Dim strDest As String
Const conRover = "ftp://ftp.storagemadeeasy.com"
Const conActiv4Pets = "spcala@activ4pets.com"
On Error GoTo Proc_Error
' initialize paths for different locations
Stop
Select Case Me.cboLocation
  Case "Long Beach"
    strAccount = "CA366"
    strPassword = "dion54"
    SPCALAExport strAccount, strPassword
    Exit Sub
Private Sub cmdFTP_Click()
Dim strAccount As String
Dim strPassword As String
Dim strDest As String
Const conRover = "ftp://ftp.storagemadeeasy.com"
Const conActiv4Pets = "spcala@activ4pets.com"
On Error GoTo Proc_Error
' initialize paths for different locations
Stop
Select Case Me.cboLocation
  Case "Long Beach"
    strAccount = "CA366"
    strPassword = "dion54"
    SPCALAExport strAccount, strPassword
    Exit Sub
I was just looking at everything and it's probably related to this:
Dim objFTP As FTP
 When you went from A2013 to A2016, did you possibly move from 32 bit Access to 64 bit Access?
 You should still have the reference for whatever your using for FTP, but if you switched Office Editions, it won't work when called.
 Paste a screen shot of the references if you can (vba editor, Tools/References).  Also check File/Account for the version of Access that you have.
Jim.
Dim objFTP As FTP
 When you went from A2013 to A2016, did you possibly move from 32 bit Access to 64 bit Access?
 You should still have the reference for whatever your using for FTP, but if you switched Office Editions, it won't work when called.
 Paste a screen shot of the references if you can (vba editor, Tools/References).  Also check File/Account for the version of Access that you have.
Jim.
<<Need more clarification. Â I put the Stop in. Â When I hit F8 nothing happens. >>
 You need to execute the form, click the button, and then the VBA editor will pop up and the STOP line will be highlighted.
 From there, you can continue code execution one line at a time using F8.
F5 will continue execution with no stepping.
Jim.
 You need to execute the form, click the button, and then the VBA editor will pop up and the STOP line will be highlighted.
 From there, you can continue code execution one line at a time using F8.
F5 will continue execution with no stepping.
Jim.
ASKER
I stepped through the code, but didn't see anything that was obvious as an error. Â What would I be looking for?
ASKER
We are still using 32 bit Access
ASKER
The error is in this section
Private Sub SPCALAExport(strAccount As String, strPassword As String)
Private Sub SPCALAExport(strAccount As String, strPassword As String)
OK, but just prior to that, when did you jump to here:
<<Proc_Error:
  Select Case Err.Number
    Case -2147219289 ' FTP switching to binary>>
 Which is the start of the error handling.  What your looking for is the line that causes you to jump to the error handler.
<<The error is in this section>>
 Move the stop to there and step through again.
Jim.
<<Proc_Error:
  Select Case Err.Number
    Case -2147219289 ' FTP switching to binary>>
 Which is the start of the error handling.  What your looking for is the line that causes you to jump to the error handler.
<<The error is in this section>>
 Move the stop to there and step through again.
Jim.
ASKER
it happens here. Â 2nd line from the bottom
Private Sub SPCALAExport(strAccount As String, strPassword As String)
Dim objFTP As FTP
Dim strPath As String
Dim imgPath As String
Dim ftpPath As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rsFail As DAO.Recordset
Dim ErrCount As Integer
Stop
Const conTARGET = "ftp://members.petfinder.com"
Const conRover = "ftp://ftp.storagemadeeasy.com"
Const conWEBPAGE = "ftp://spcala.com"
Const PathName = "\\databases\access2015\Pe tfinder"
On Error GoTo Proc_Error
' initialize progress tracking textboxes
Me!txtAvailable = Me.RecordsetClone.RecordCo unt
If Me.cboLocation = "SPCALA Webpage" Then
  Me!txtAvailable = DCount("*", "qryWebpageExport")
End If
Me!txtSent = 0
Me!txtNoPic = 0
Me!txtTotal = 0
ErrCount = 0
' export the query
If Me.cboLocation = "SPCALA Webpage" Then
  strPath = PathName & "\adoptable.txt"
  'Application.ExportXML ObjectType:=acExportQuery, _
  'DataSource:="qryWebpageEx port", _
  'datatarget:=strPath
  DoCmd.TransferText acExportDelim, "Webpage Export Specification", _
   "qryWebpageExport", strPath, True
  Set objFTP = New FTP
  With objFTP
    .SourceFile = strPath
    .FtpURL = conWEBPAGE
    .DestinationFile = "adoptable.txt"
    .AutoCreateRemoteDir = False
    .ConnectToFTPHost strAccount, strPassword
    .UploadFileToFTPServer
  End With
Else
  strPath = PathName & "\" & strAccount & ".txt"
  DoCmd.TransferText acExportDelim, "Petfinder Export Specification", "qryPetfinderExport", strPath, True
  Set objFTP = New FTP
  With objFTP
    .SourceFile = strPath
    .FtpURL = conTARGET
    .DestinationFile = "/import/" & strAccount & ".txt"
    .AutoCreateRemoteDir = False
    .ConnectToFTPHost strAccount, strPassword
    .UploadFileToFTPServer
  End With
End If
'export all pictures
imgPath = DLookup("DefaultImagePath" , "tbl_ImageDefaultPath", "ImageType='SoftSlips'")
Set db = CurrentDb
Set rsFail = db.OpenRecordset("tblPetfi nderFailur es", dbOpenDynaset)
If Me.cboLocation = "SPCALA Webpage" Then
  Set rs = db.OpenRecordset("qryWebpa geExport", dbOpenDynaset)
Else
  Set rs = Me.RecordsetClone
End If
rs.MoveFirst
With objFTP
  If Me.cboLocation = "SPCALA Webpage" Then
    .FtpURL = conWEBPAGE
  Else
    .FtpURL = conTARGET
  End If
  .ConnectToFTPHost strAccount, strPassword
End With
' set initial ftp
If Me.cboLocation = "SPCALA Webpage" Then
  ftpPath = ""
Else
  ftpPath = "/import/photos/"
End If
Do Until rs.EOF
TryAgain:
  If Len(rs!SoftSlipPicPathFile & "") <> 0 Then
    If Dir(rs!SoftSlipPicPathFile ) <> "" Then
      If Me.cboLocation <> "SPCALA Webpage" Then
        Me.Bookmark = rs.Bookmark
      End If
      With objFTP
        '.SourceFile = imgPath & "\" & rs!SoftSlip & ".jpg"
        .SourceFile = rs!SoftSlipPicPathFile
        .DestinationFile = ftpPath & rs!SoftSlip & ".jpg"
        .UploadFileToFTPServer
      End With
      ' since the focus is now on the photos folder, we don't need the path any more
      'If Me.cboLocation <> "SPCALA Webpage" Then
        ftpPath = ""
      'End If
      Me!txtUploading = rs!SoftSlip
      Me!txtSent = Me!txtSent + 1
    Else
      Me!txtNoPic = Me!txtNoPic + 1
    End If
  Else
    Me!txtNoPic = Me!txtNoPic + 1
  End If
  Me!txtTotal = Me!txtTotal + 1
  Me.Repaint
  rs.MoveNext
Loop
PROC_EXIT:
  On Error Resume Next
  Set objFTP = Nothing
  Exit Sub
 Â
Proc_Error:
  Select Case Err.Number
    Case -2147219289 ' FTP switching to binary
      'MsgBox "FTP switching to binary, retrying " & rs!SoftSlip
      ErrCount = ErrCount + 1
      If ErrCount < 6 Then
        With objFTP
          If Me.cboLocation = "SPCALA Webpage" Then
            .FtpURL = conWEBPAGE
          Else
            .FtpURL = conTARGET
          End If
          .ConnectToFTPHost strAccount, strPassword
        End With
        Resume TryAgain
      Else
        ' msgbox commented out per JR's request
        'MsgBox "Too many FTP errors for " & rs!SoftSlip & ", skipping to next picture"
        rsFail.AddNew
          rsFail!SoftSlip = rs!SoftSlip
          rsFail!faildate = Now
        rsFail.Update
       Â
        ErrCount = 0
        rs.MoveNext
        If rs.EOF Then
          Resume PROC_EXIT
        Else
          Resume TryAgain
        End If
      End If
    Case Else
      MsgBox "Error " & Err.Number & " in cmdFTP_Click:" & vbCrLf & Err.Description
  End Select
Private Sub SPCALAExport(strAccount As String, strPassword As String)
Dim objFTP As FTP
Dim strPath As String
Dim imgPath As String
Dim ftpPath As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rsFail As DAO.Recordset
Dim ErrCount As Integer
Stop
Const conTARGET = "ftp://members.petfinder.com"
Const conRover = "ftp://ftp.storagemadeeasy.com"
Const conWEBPAGE = "ftp://spcala.com"
Const PathName = "\\databases\access2015\Pe
On Error GoTo Proc_Error
' initialize progress tracking textboxes
Me!txtAvailable = Me.RecordsetClone.RecordCo
If Me.cboLocation = "SPCALA Webpage" Then
  Me!txtAvailable = DCount("*", "qryWebpageExport")
End If
Me!txtSent = 0
Me!txtNoPic = 0
Me!txtTotal = 0
ErrCount = 0
' export the query
If Me.cboLocation = "SPCALA Webpage" Then
  strPath = PathName & "\adoptable.txt"
  'Application.ExportXML ObjectType:=acExportQuery,
  'DataSource:="qryWebpageEx
  'datatarget:=strPath
  DoCmd.TransferText acExportDelim, "Webpage Export Specification", _
   "qryWebpageExport", strPath, True
  Set objFTP = New FTP
  With objFTP
    .SourceFile = strPath
    .FtpURL = conWEBPAGE
    .DestinationFile = "adoptable.txt"
    .AutoCreateRemoteDir = False
    .ConnectToFTPHost strAccount, strPassword
    .UploadFileToFTPServer
  End With
Else
  strPath = PathName & "\" & strAccount & ".txt"
  DoCmd.TransferText acExportDelim, "Petfinder Export Specification", "qryPetfinderExport", strPath, True
  Set objFTP = New FTP
  With objFTP
    .SourceFile = strPath
    .FtpURL = conTARGET
    .DestinationFile = "/import/" & strAccount & ".txt"
    .AutoCreateRemoteDir = False
    .ConnectToFTPHost strAccount, strPassword
    .UploadFileToFTPServer
  End With
End If
'export all pictures
imgPath = DLookup("DefaultImagePath"
Set db = CurrentDb
Set rsFail = db.OpenRecordset("tblPetfi
If Me.cboLocation = "SPCALA Webpage" Then
  Set rs = db.OpenRecordset("qryWebpa
Else
  Set rs = Me.RecordsetClone
End If
rs.MoveFirst
With objFTP
  If Me.cboLocation = "SPCALA Webpage" Then
    .FtpURL = conWEBPAGE
  Else
    .FtpURL = conTARGET
  End If
  .ConnectToFTPHost strAccount, strPassword
End With
' set initial ftp
If Me.cboLocation = "SPCALA Webpage" Then
  ftpPath = ""
Else
  ftpPath = "/import/photos/"
End If
Do Until rs.EOF
TryAgain:
  If Len(rs!SoftSlipPicPathFile
    If Dir(rs!SoftSlipPicPathFile
      If Me.cboLocation <> "SPCALA Webpage" Then
        Me.Bookmark = rs.Bookmark
      End If
      With objFTP
        '.SourceFile = imgPath & "\" & rs!SoftSlip & ".jpg"
        .SourceFile = rs!SoftSlipPicPathFile
        .DestinationFile = ftpPath & rs!SoftSlip & ".jpg"
        .UploadFileToFTPServer
      End With
      ' since the focus is now on the photos folder, we don't need the path any more
      'If Me.cboLocation <> "SPCALA Webpage" Then
        ftpPath = ""
      'End If
      Me!txtUploading = rs!SoftSlip
      Me!txtSent = Me!txtSent + 1
    Else
      Me!txtNoPic = Me!txtNoPic + 1
    End If
  Else
    Me!txtNoPic = Me!txtNoPic + 1
  End If
  Me!txtTotal = Me!txtTotal + 1
  Me.Repaint
  rs.MoveNext
Loop
PROC_EXIT:
  On Error Resume Next
  Set objFTP = Nothing
  Exit Sub
 Â
Proc_Error:
  Select Case Err.Number
    Case -2147219289 ' FTP switching to binary
      'MsgBox "FTP switching to binary, retrying " & rs!SoftSlip
      ErrCount = ErrCount + 1
      If ErrCount < 6 Then
        With objFTP
          If Me.cboLocation = "SPCALA Webpage" Then
            .FtpURL = conWEBPAGE
          Else
            .FtpURL = conTARGET
          End If
          .ConnectToFTPHost strAccount, strPassword
        End With
        Resume TryAgain
      Else
        ' msgbox commented out per JR's request
        'MsgBox "Too many FTP errors for " & rs!SoftSlip & ", skipping to next picture"
        rsFail.AddNew
          rsFail!SoftSlip = rs!SoftSlip
          rsFail!faildate = Now
        rsFail.Update
       Â
        ErrCount = 0
        rs.MoveNext
        If rs.EOF Then
          Resume PROC_EXIT
        Else
          Resume TryAgain
        End If
      End If
    Case Else
      MsgBox "Error " & Err.Number & " in cmdFTP_Click:" & vbCrLf & Err.Description
  End Select
<<it happens here. Â 2nd line from the bottom>>
 No, getting there is a result of hitting an error.  The bottom of that procedure, including the second line from the bottom is all error handling code.
 As your stepping through the code, you'll try to execute a line, and then all of a sudden it will jump to here:
 Proc_Error:
  Select Case Err.Number
 Which is the start of the error handling code.   What should be happening if everything was working correctly is that you would step through the entire procedure until you hit this:
PROC_EXIT:
  On Error Resume Next
  Set objFTP = Nothing
  Exit Sub
 which is the normal exit and you would never jump to here:
Proc_Error:
  Select Case Err.Number
 or execute any of the code below that line.
Jim.
 No, getting there is a result of hitting an error.  The bottom of that procedure, including the second line from the bottom is all error handling code.
 As your stepping through the code, you'll try to execute a line, and then all of a sudden it will jump to here:
 Proc_Error:
  Select Case Err.Number
 Which is the start of the error handling code.   What should be happening if everything was working correctly is that you would step through the entire procedure until you hit this:
PROC_EXIT:
  On Error Resume Next
  Set objFTP = Nothing
  Exit Sub
 which is the normal exit and you would never jump to here:
Proc_Error:
  Select Case Err.Number
 or execute any of the code below that line.
Jim.
ASKER
First off thank you for helping. Â This is critical to us. Â We are the Society for the Prevention of Cruelty to Animals Los Angeles. Â This upload sends all of our animal information to our web site. Â So when it's not working everything is outdated
I'm not a VBA programmer, so I need your help.  I don't understand when you say  As your stepping through the code, you'll try to execute a line, and then all of a sudden it will jump to here:
I'm not a VBA programmer, so I need your help.  I don't understand when you say  As your stepping through the code, you'll try to execute a line, and then all of a sudden it will jump to here:
ASKER
I see that you charge for your services. Â Could you fix this if you had the database? Â We don't have a lot of money, but I could get some approved for this.
Ah, this is the DB then that Miriam Bizup worked on.
 I really don't have the time, but if nothing's been done other than moving to A2016 and it is still 32 bit, then it should be a fast fix ( actually don't understand why it broke).  The fastest thing would be for me to remote in. Â
 I'll send you a Private message in a minute with my phone number.
 Give me a call and we'll discuss.
Jim.
 I really don't have the time, but if nothing's been done other than moving to A2016 and it is still 32 bit, then it should be a fast fix ( actually don't understand why it broke).  The fastest thing would be for me to remote in. Â
 I'll send you a Private message in a minute with my phone number.
 Give me a call and we'll discuss.
Jim.
ASKER
Yes. Â Miriam is a HUGE help, but not available at this time.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks, again for all the help