How to refer to collection in a called function?

Lierduh

New member
Local time
Tomorrow, 05:45
Joined
Jun 1, 2003
Messages
7
I think the code probably makes more sense for the experts than explaining.
Code:
Function Duplicator(strSource As String, strTarget As String, strSkip As String, strIDName As String, varIDVal As Variant, varSetTo As Variant, Optional strExtrSQL As Variant)

...<removed unrelated code>

'Find out the size of the array
intSetToNo = UBound(varSetTo, 1)

Set Src = CurDB.OpenRecordset(strSQLs, dbOpenForwardOnly)
Set Trgt = CurDB.OpenRecordset(strSQLt, dbOpenDynaset, dbAppendOnly)

If Not Src.EOF Then
  Do Until Src.EOF
    Trgt.AddNew
    For Each fldLoop In Src.Fields
          If InStr(strSkip, fldLoop.Name) = 0 Then 'skip those field names included in strSkip
              Trgt(fldLoop.Name) = Src(fldLoop.Name)
          End If
    Next fldLoop
    
    'Now add those pre-set values from the array
    For intCnt = 0 To intSetToNo
       Trgt(varSetTo(intCnt, 0)) = varSetTo(intCnt, 1)
    Next intCnt
    
    Trgt.Update
  Src.MoveNext
  Loop
Else 'src.eof
  MsgBox "Source.EOF!"
End If 'src.eof

...
End Function

Normally I can call the function and having the preset value and field name in the array. eg.

varSetTo(0,0)="ShippedQty"
varSetTo(0,1)=10
varSetTo(1,0)="PrevShippedQty"
varSetTo(1,1)=2


Now I need to set the value for a certain field to the value of another field in the source recordset. eg.

varSetTo(0,0)="ShippedQty"
varSetTo(0,1)= < Src!PrevShippedQty > + 10

                     ^^^^^^^^^^^^^^^^^^^
My question is how do I refer to a recordset inside a function which the code calls?

Thank you for reading this!
 
Last edited:

Users who are viewing this thread

Back
Top Bottom