Error 91

luzz

Registered User.
Local time
Yesterday, 20:16
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
 
What is modifyRecords?
Where is it Declared and Set?Show the whole procedure/Sub.
 
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.
 
hello, if you want to change the name of collection, use Find and Replace (ctrl-H).

replace MaximRecords with modifyRecords.
 
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

Back
Top Bottom