Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Item Not Found Error

Status
Not open for further replies.

kopy

Technical User
May 30, 2002
141
US
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
 
What is the SQL code of the subLatheOps's RecordSource ?
Seems that this query doesn't return a field named txtProgram#.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The Record Source for Forms![frmPartInfo]![subLatheOps] is SELECT FROM tblLatheOps;

Thanks again.
 
Really ?
So, you have a syntax error, I guess ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks, I found it.
Draft = rst![txtProgram#] & "*.txt" should be
Draft = rst![Program#] & "*.txt".

- Kopy
 
how are ya kopy . . .

On seeing this post it brought back memory of your origional ([blue]PHV[/blue] see thread705-1369417). Either I received no notice or may have deleted the notice by accident (highly unlikely). In any case apologies for the wait.

At the time of the origional thread, I simulated what you presented with no problemo . . . hence the code. You now say:
kopy said:
[blue]My current problem is that in the line Draft = rst![txtProgram#] & "*.txt", I get an "[purple]Item not found in this collection[/purple]" error.[/blue]
The above shows that [blue]sfrm[/blue] & [blue]rst[/blue] were set properly. It can't seem to find [blue][txtProgram#][/blue] . . .
Check the [blue]name porperty[/blue] of this field in the subform, and do post that requested by [blue]PHV[/blue] . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top