Error 91 (1 Viewer)

luzz

Registered User.
Local time
Yesterday, 21:32
Joined
Aug 23, 2017
Messages
346
Hi all, I am facing issue with this error "91" object variable or with block variable not set at this line of code. Can you help me?

I have declare and set the variable at the start of my coding.

Code:
' loop on each item in maximrecords collection
[B]    For i = 1 To modifyRecords.Count[/B] This line of code turn yellow
        Set rec = modifyRecords.Item(i)
        thisLoss = 0
        If Nz(rec.NettWeight, 0) <> 0 Then _
            thisLoss = Nz(rec.GrossWeight, 0) - Nz(rec.NettWeight, 0) / Nz(rec.NettWeight, 0) * 100
        'Insert data to MaximMaintable by using SQL
        Call fnAnySQL(strSQL, rec.GLGPO, rec.Mill, rec.solidPrinting, rec.Reference, _
            rec.FunctionalFinish, rec.MRName, rec.Buyer, rec.MXDPO, _
            rec.GLA, rec.StyleNO, rec.FabricDelivery, rec.GarmentDelDate, _
            rec.Country, rec.Fabrication, rec.afterFabricationWashWidth, rec.Width, _
            rec.FinishedGoods, rec.GSMPerSqYd, rec.GSMAfterWash, rec.Colour, _
            rec.GroundColour, rec.ComboName, rec.LabDipCode, rec.samplerRequirement, _
            rec.GrossWeight, rec.NettWeight, rec.Lbs, thisLoss, rec.Yds, rec.Remarks, _
            rec.GarmentSketch, rec.GarmentSketch2, rec.GarmentSketch3, rec.GarmentSketch4, _
            rec.GarmentSketch5, rec.PrintedRemarks, rec.FabricWeight, rec.UnitPrice, rec.Line, _
            rec.PPSample, rec.POStatus, rec.Amendment, rec.sketchMark1, rec.sketchMark2, _
            rec.sketchMark3, rec.sketchMark4, rec.sketchMark5)
    Next
 

JHB

Have been here a while
Local time
Today, 06:32
Joined
Jun 17, 2012
Messages
7,732
What is modifyRecords?
Where is it Declared and Set?Show the whole procedure/Sub.
 

Cronk

Registered User.
Local time
Today, 14:32
Joined
Jul 4, 2013
Messages
2,774
If I was a betting person, I'd put money on the bet that the 'collection' modifyRecords does not exist because that what the error message is saying. It's not the line in yellow, it is a problem somewhere before.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:32
Joined
May 7, 2009
Messages
19,249
hello, if you want to change the name of collection, use Find and Replace (ctrl-H).

replace MaximRecords with modifyRecords.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 23:32
Joined
Feb 28, 2001
Messages
27,444
if modifyRecords is a recordset, it has to be declared and open already. The text part of the message is object variable or with block variable not set which EITHER means that modifyRecords is not DEFINED (i.e. no such variable) or that you have used it before you did some kind of statement like SET modifyRecords = OpenRecordset( ... ) (i.e. the datastructure currently is not open.). Stated another way, the 2nd case I mentioned would pass the test of IF modifyRecords IS NOTHING in VBA.
 

Users who are viewing this thread

Top Bottom