[RESOLVED] Dir on partial name
I need to locate and print PDF files. However, the only data I have available is the 1st 7 characters. Each file will have a different 7 starting characters. No duplications.
This is what I have so far:
Code:
Dim foundit As String
'==============================
Set rs1 = New ADODB.Recordset
'==============================
sql = "SELECT * FROM PRTD WHERE LTRIM(RTRIM([CUST])) = " & "'" & "TRIA" & "'"
sql = sql & " ORDER BY [PRTD]"
rs1.Open sql, CnxnTechSQL, adOpenKeyset, adLockReadOnly, adCmdText
If Not rs1.BOF And Not rs1.EOF Then
rs1.MoveFirst
Do
If rs1![actinact] = "A" Then
name = "C:\Program Files\Junior\PDF\" & rs1![prtd] & "*)"
foundit = Dir(name)
If foundit <> "" Then
'
Else
msg = msg & rs1![prtd] & vbCrLf
End If
End If
rs1.MoveNext
Loop While Not rs1.EOF
End If
rs1.Close
Set rs1 = Nothing
'=================
Is this the correct way to approach this problem? I have never tried this when I don't have the full file name.