am brain dead (1 Viewer)

MIkeD666

Registered User.
Local time
Today, 04:32
Joined
Jan 12, 2019
Messages
59
Good morning every one. I have been up since 4.30. watched some tv and had a coffe then set to working at 5. 10. it's now 7.30 and am ready to go back to bed for a hour to recharge my body and my peanut size brain. But I have brain block, or am just stupid.

My simple problem is I have a form (a sales invoice form) that it working wonderfully, with a sub form. In this sub form is the list of products sold on the invoice.
I now wish to do a loop get the stock id code for each row, in the sub form.
I have set a count variable to hold the number of rows . after that am l brain dead.

how do I count the rows and get a value such stock id field form each row, as I go through the loop. Thanks in advance for replying. one day I might be good enough to answer some question on here rather than just ask.
MIKE
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:32
Joined
May 7, 2009
Messages
19,247
on vba approach, you need to open the subform's recordset:
Code:
Public Function fnSubfrmIDs() As Collection
Dim coll As New Collection
With Form!yourFormName!yourSubformName.Form.RecordsetClone
    If Not (.Bof And .Eof) Then .MoveFirst
    While Not .Eof
        coll.Add ![ID Code here]
        .MoveNext
    Wend
End With
Set fnSubfrmIDs = coll
End Function
this will return a collection object.
to get the number of [id code]:
Code:
Dim coll As Collection
dim var As Variant
Set coll = fnSubfrmIDs()
' how many item code
debug.print coll.count
' list all item code
for each var in coll
    debug.print var
next
 

MIkeD666

Registered User.
Local time
Today, 04:32
Joined
Jan 12, 2019
Messages
59
Thanks I will try it later and let you know how I got on
 

Users who are viewing this thread

Top Bottom