A
AccessARS
My goal in the following code is to use the Array in the For Loop to generate
the field names by concatenate the numbers 1-4 at the end of the first part
of the field names
i.e. HiPathKey1, HiPathKey2, HiPathKey3... unfortunately the method I'm
using below does not seem to work...Error:"Item not found in this collection."
Is this possible?
If so, how?
Thank you in advance for you assistance.
CODE:
Set mydatabase = CurrentDb
Set rsttable = mydatabase.OpenRecordset("tbl_EworkforceEmployees")
Set rst = mydatabase.OpenRecordset("tbl_HiPathAgentKey")
Key = Array("1", "2", "3", "4")
rst.AddNew
For i = 0 To 3
With rst
rsttable.MoveFirst
Do While Not rsttable.EOF
Do While IsNull(rsttable!HiPathKey & Key(i))
rsttable.MoveNext
Loop
If rsttable.EOF = False Then
.AddNew
rst!EworkforceID = rsttable!EworkforceID
rst!HiPathAgentKey = rsttable!HiPathKey & Key(i)
rst!AgentIDSite = rsttable!HiPath_site_id_ & Key(i)
.Update
End If
If rsttable.EOF = False Then
rsttable.MoveNext
DoEvents
DoEvents
End If
Loop
End With
Next i
the field names by concatenate the numbers 1-4 at the end of the first part
of the field names
i.e. HiPathKey1, HiPathKey2, HiPathKey3... unfortunately the method I'm
using below does not seem to work...Error:"Item not found in this collection."
Is this possible?
If so, how?
Thank you in advance for you assistance.
CODE:
Set mydatabase = CurrentDb
Set rsttable = mydatabase.OpenRecordset("tbl_EworkforceEmployees")
Set rst = mydatabase.OpenRecordset("tbl_HiPathAgentKey")
Key = Array("1", "2", "3", "4")
rst.AddNew
For i = 0 To 3
With rst
rsttable.MoveFirst
Do While Not rsttable.EOF
Do While IsNull(rsttable!HiPathKey & Key(i))
rsttable.MoveNext
Loop
If rsttable.EOF = False Then
.AddNew
rst!EworkforceID = rsttable!EworkforceID
rst!HiPathAgentKey = rsttable!HiPathKey & Key(i)
rst!AgentIDSite = rsttable!HiPath_site_id_ & Key(i)
.Update
End If
If rsttable.EOF = False Then
rsttable.MoveNext
DoEvents
DoEvents
End If
Loop
End With
Next i