Item not found in this collection

Dr_Worm

Board Regular
Joined
Jul 28, 2003
Messages
103
I’m getting the error message “Item not found in this Collection” when I try to run the following code:

Function MakeLabels()

Dim db As DAO.Database
Dim rst1 As DAO.Recordset
Dim rst2 As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Dim strSQL As String
Dim Counter As Integer
Dim txt1 As String
Dim qtn As Long
Dim dt1 As Date
Dim num1 As Integer
Dim num2 As Integer
Dim dt2 As Date
Dim i As Integer
Dim txt3 As String
Dim dt3 As Date
Dim txt4 As String
Dim txt5 As String
Dim txt6 As String
Dim txt7 As String
Dim yn1 As Integer
Dim txt8 As String
Dim txt9 As String
Dim txt10 As String
Dim txt11 As String
Dim txt12 As String
Dim rwrk As Long
Dim txt13 As String
Dim txt14 As String
Dim txt15 As String
Dim txt16 As String
Dim txt17 As String
Dim txt18 As String
Dim txt19 As String
Dim txt20 As String
Dim txt21 As String
Dim txt22 As String
Dim txt23 As String
Dim txt24 As String
Dim txt25 As String
Dim txt2 As String
Dim txt26 As String
Dim txt27 As String
Dim txt28 As String
Dim txt29 As String
Dim dt4 As Date
Dim txt30 As String

Set db = CurrentDb()
Set qdf = db.QueryDefs("CUTLISTData")
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set rst1 = qdf.OpenRecordset
Set rst2 = db.OpenRecordset("PrintData")
strSQL = "DELETE * FROM PrintData;"
DoCmd.RunSQL (strSQL)
With rst1
.MoveFirst
Do Until .EOF
txt1 = !PartDescpirtion
qtn = !QuoteNo
dt1 = !DateReceived
num1 = !Length
num2 = !Width
dt2 = !DateReleased
Counter = !Quantity
txt3 = !Type
dt3 = !DateRequired
txt4 = !Material
txt5 = !SiteDocNo
txt6 = !JobName
txt7 = !BatchNo
yn1 = !Internal
txt8 = !Hand
txt9 = !UnitRmCab
txt10 = !SpecialOps
txt11 = !L1Name
txt12 = !L1Material
rwrk = !ReworkNumber
txt13 = !ContactName
txt14 = !L2Name
txt15 = !L2Material
txt16 = !Field24
txt17 = !Field25
txt18 = !W1Name
txt19 = !W1Material
txt20 = !Field28
txt21 = !Field29
txt22 = !W2Name
txt23 = !W2Material
txt24 = !Field32
txt25 = !Field33
txt2 = !Field34
txt26 = !BoringProg
txt27 = !Comments
txt28 = !PaintLacLam
txt29 = !RWCauseCode
dt4 = !DateSent
txt30 = !PrintQty
With rst2
For i = 1 To Counter
.AddNew
!PartDescription = txt1
!QuoteNo = qtn
!DateReceived = dt1
!Length = num1
!Width = num2
!DateReleased = dt2
!Quantity = txt30
!Type = txt3
!DateRequired = dt3
!Material = txt4
!SiteDocNo = txt5
!JobName = txt6
!BatchNo = txt7
!Internal = yn1
!Hand = txt8
!UnitRmCab = txt9
!SpecialOps = txt10
!L1Name = txt11
!L1Material = txt12
!ReworkNumber = rwrk
!ContactName = txt13
!L2Name = txt14
!L2Material = txt15
!Field24 = txt16
!Field25 = txt17
!W1Name = txt18
!W1Material = txt19
!Field28 = txt20
!Field29 = txt21
!W2Name = txt22
!W2Material = txt23
!Field32 = txt24
!Field33 = txt25
!Field34 = txt2
!BoringProg = txt26
!Comments = txt27
!PaintLacLam = txt28
!RWCauseCode = txt29
!DateSent = dt4
.Update
Next i
End With
.MoveNext
Loop
End With
End Function

Any help would be great. I’m learning as I go. Workmates keep asking me “Can we do this……” and my usual response is “Yes, but I don’t know how to do that…YET”
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Sounds like a spelling error on a filed name. Try double checking on the line of code it highlights when it bombs out.

Peter
 
Upvote 0

Forum statistics

Threads
1,223,792
Messages
6,174,611
Members
452,574
Latest member
hang_and_bang

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top