I have a Command Button on a form that displays whether an associated file is available for a Program Number on a subform.
If an associated file is detected the font is green and if not it is black.
The Program #'s are on a subform.
What I'd like to do is go through all of the Program Numbers on the subform and if any one of them is detected turn the font to green. If none are tected the font will be black.
I've already gotten some great asisstance from this forum. My current problem is that in the line Draft = rst![txtProgram#] & "*.txt", I get an "Item not found in this collection" error.
Any help will be greatly appreciated. Thanks in advance, Kopy.
===========================================================
Public Sub ProgFileExistLathe()
Dim rst As DAO.Recordset, sfrm As Form, flg As Boolean
Dim picPath As String, Draft As String, Pic As String, strFile As String
picPath = "C:\Impact Consulting\Computer Care Associates" & _
"\H G Cockrill\CNC Programs\"
Set sfrm = Forms![frmPartInfo]![subLatheOps].Form
Set rst = sfrm.RecordsetClone
If Not rst.BOF Then
Do
Draft = rst![txtProgram#] & "*.txt"
If Trim(Dir(picPath & Draft, vbNormal) & "") <> "" Then
flg = True 'File Found!
Exit Do
End If
rst.MoveNext
Loop Until rst.EOF
End If
If flg Then
Pic = picPath & strFile
Forms![frmPartInfo]!Command64.ForeColor = RGB(0, 128, 0)
Forms![frmPartInfo]!Command64.FontWeight = 700
Else
Forms![frmPartInfo]!Command64.ForeColor = RGB(0, 0, 0)
Forms![frmPartInfo]!Command64.FontWeight = 400
End If
Set rst = Nothing
Set frm = Nothing
End Sub
If an associated file is detected the font is green and if not it is black.
The Program #'s are on a subform.
What I'd like to do is go through all of the Program Numbers on the subform and if any one of them is detected turn the font to green. If none are tected the font will be black.
I've already gotten some great asisstance from this forum. My current problem is that in the line Draft = rst![txtProgram#] & "*.txt", I get an "Item not found in this collection" error.
Any help will be greatly appreciated. Thanks in advance, Kopy.
===========================================================
Public Sub ProgFileExistLathe()
Dim rst As DAO.Recordset, sfrm As Form, flg As Boolean
Dim picPath As String, Draft As String, Pic As String, strFile As String
picPath = "C:\Impact Consulting\Computer Care Associates" & _
"\H G Cockrill\CNC Programs\"
Set sfrm = Forms![frmPartInfo]![subLatheOps].Form
Set rst = sfrm.RecordsetClone
If Not rst.BOF Then
Do
Draft = rst![txtProgram#] & "*.txt"
If Trim(Dir(picPath & Draft, vbNormal) & "") <> "" Then
flg = True 'File Found!
Exit Do
End If
rst.MoveNext
Loop Until rst.EOF
End If
If flg Then
Pic = picPath & strFile
Forms![frmPartInfo]!Command64.ForeColor = RGB(0, 128, 0)
Forms![frmPartInfo]!Command64.FontWeight = 700
Else
Forms![frmPartInfo]!Command64.ForeColor = RGB(0, 0, 0)
Forms![frmPartInfo]!Command64.FontWeight = 400
End If
Set rst = Nothing
Set frm = Nothing
End Sub