H
Helpme_Rhonda
General Description:
I am adding many new records from one recordset, to another.
I know this begins with the AddNew method and then the fields are explicitly
declared i.e. (Recordset!Field1 = Value). I don't want to explicitly write
out all of the fields so i want to do this with a loop. It seems like it
should simple but its F***ing frustrating. I already know that my recordsets
have the same number of fields.
Here's what I got:
' This Function strips values from one recordset and places those values 'as
a new row
'in the recordset_to object
Function Row_Insert(rcd_set_to As Recordset, rcd_set_from As Recordset)
Dim intCounter As Long
intNumberFields = rcd_set_from.Fields.Count
rcd_set_to.AddNew
For intCounter = 0 To intNumberFields - 1
temp = Get_Field_Name(intCounter, rcd_set_to)
Eval (temp)
Next intCounter
rcd_set_to.Update
End Function
' This function returns the Fieldnames for the index value given
Function Get_Field_Name(indx As Long, rcd_set As Recordset) As String
Get_Field_Name = "rcd_set_to!" & rcd_set.Fields(indx).Name & " =
rcd_set_from.Fields(intCounter).Value"
End Function
Here is the error:
Run-time errror '2482':
MS Office Access cant find the name 'rcd_set_to' you entered in the
expression becuase it's moodier than your emo girlfriend/boyfriend.
So the string function to evaluate is
rcd_set_to!Field_name = rcd_set_from.Fields(intCounter).Value
which works if I break at runtime then debug.print the string and continue
with the string in.
I am adding many new records from one recordset, to another.
I know this begins with the AddNew method and then the fields are explicitly
declared i.e. (Recordset!Field1 = Value). I don't want to explicitly write
out all of the fields so i want to do this with a loop. It seems like it
should simple but its F***ing frustrating. I already know that my recordsets
have the same number of fields.
Here's what I got:
' This Function strips values from one recordset and places those values 'as
a new row
'in the recordset_to object
Function Row_Insert(rcd_set_to As Recordset, rcd_set_from As Recordset)
Dim intCounter As Long
intNumberFields = rcd_set_from.Fields.Count
rcd_set_to.AddNew
For intCounter = 0 To intNumberFields - 1
temp = Get_Field_Name(intCounter, rcd_set_to)
Eval (temp)
Next intCounter
rcd_set_to.Update
End Function
' This function returns the Fieldnames for the index value given
Function Get_Field_Name(indx As Long, rcd_set As Recordset) As String
Get_Field_Name = "rcd_set_to!" & rcd_set.Fields(indx).Name & " =
rcd_set_from.Fields(intCounter).Value"
End Function
Here is the error:
Run-time errror '2482':
MS Office Access cant find the name 'rcd_set_to' you entered in the
expression becuase it's moodier than your emo girlfriend/boyfriend.
So the string function to evaluate is
rcd_set_to!Field_name = rcd_set_from.Fields(intCounter).Value
which works if I break at runtime then debug.print the string and continue
with the string in.