Hi all,
I wrote this routine temporarily using a local table in my front-end database. No problems... however, when I changed it to use the linked table, I'm getting the famous (I've seen so many conversations concerning this...) VBA: 3251 error - Current provider does not support the necessary interface for Index functionality.
In support.microsoft.com, I found a Jan 27, 2009 Run-time error 3251 document stating that this error has been fixed in R06670 Service Pack. Has anyone downloaded this service pack and does it fix the 3251 problem?
Or - maybe something I can change in my code? From what I gather from my searching is I can't seek on either a primary or alt key with a linked table. I've asked for the download but I haven't received it yet.
Thanks!
Dim cnn As ADODB.Connection
Dim errCur As ADODB.Error
Dim lngValue As Long
Dim rstEmpSkill As ADODB.Recordset ' this will be tblEmployeeSkillSet
Dim varValueArray As Variant
' if nothing selected, exit
If Me.lstEmps.ItemsSelected.Count = 0 Or Me.lstTasks.ItemsSelected.Count = 0 Then
MsgBox "You must select at least one entry from both lists to continue", vbCritical
Exit Sub
End If
Set cnn = CurrentProject.Connection
Set rstEmpSkill = New ADODB.Recordset
rstEmpSkill.CursorType = adOpenDynamic
rstEmpSkill.LockType = adLockOptimistic
rstEmpSkill.Open "tblEmployeeSkillSet", cnn, , , adCmdTableDirect
rstEmpSkill.Index = "UniqueSkillSet" ' index is two long fields
'----------------------------------------------
Dim varItem As Variant
Dim varItem2 As Variant
' Enumerate through listbox selected items and if not duplicate on foreign key, add to tblEmployeeSkillSet.
' the two values from the lstbox contain the two long fields of the foreign key
'
For Each varItem In Me.lstEmps.ItemsSelected
For Each varItem2 In Me.lstTasks.ItemsSelected
varValueArray = Array(Me.lstEmps.ItemData(varItem), Me.lstTasks.ItemData(varItem2))
rstEmpSkill.Seek varValueArray, adSeekFirstEQ
If rstEmpSkill.EOF Then ' record doesn't exist, add it
rstEmpSkill.AddNew
rstEmpSkill.Fields("intEmployeeID") = Me.lstEmps.ItemData(varItem)
rstEmpSkill.Fields("intSkillID") = Me.lstTasks.ItemData(varItem2)
rstEmpSkill.Update
End If
skipdups:
Next varItem2
Next varItem
MsgBox "Your selections have been processed..."
I wrote this routine temporarily using a local table in my front-end database. No problems... however, when I changed it to use the linked table, I'm getting the famous (I've seen so many conversations concerning this...) VBA: 3251 error - Current provider does not support the necessary interface for Index functionality.
In support.microsoft.com, I found a Jan 27, 2009 Run-time error 3251 document stating that this error has been fixed in R06670 Service Pack. Has anyone downloaded this service pack and does it fix the 3251 problem?
Or - maybe something I can change in my code? From what I gather from my searching is I can't seek on either a primary or alt key with a linked table. I've asked for the download but I haven't received it yet.
Thanks!
Dim cnn As ADODB.Connection
Dim errCur As ADODB.Error
Dim lngValue As Long
Dim rstEmpSkill As ADODB.Recordset ' this will be tblEmployeeSkillSet
Dim varValueArray As Variant
' if nothing selected, exit
If Me.lstEmps.ItemsSelected.Count = 0 Or Me.lstTasks.ItemsSelected.Count = 0 Then
MsgBox "You must select at least one entry from both lists to continue", vbCritical
Exit Sub
End If
Set cnn = CurrentProject.Connection
Set rstEmpSkill = New ADODB.Recordset
rstEmpSkill.CursorType = adOpenDynamic
rstEmpSkill.LockType = adLockOptimistic
rstEmpSkill.Open "tblEmployeeSkillSet", cnn, , , adCmdTableDirect
rstEmpSkill.Index = "UniqueSkillSet" ' index is two long fields
'----------------------------------------------
Dim varItem As Variant
Dim varItem2 As Variant
' Enumerate through listbox selected items and if not duplicate on foreign key, add to tblEmployeeSkillSet.
' the two values from the lstbox contain the two long fields of the foreign key
'
For Each varItem In Me.lstEmps.ItemsSelected
For Each varItem2 In Me.lstTasks.ItemsSelected
varValueArray = Array(Me.lstEmps.ItemData(varItem), Me.lstTasks.ItemData(varItem2))
rstEmpSkill.Seek varValueArray, adSeekFirstEQ
If rstEmpSkill.EOF Then ' record doesn't exist, add it
rstEmpSkill.AddNew
rstEmpSkill.Fields("intEmployeeID") = Me.lstEmps.ItemData(varItem)
rstEmpSkill.Fields("intSkillID") = Me.lstTasks.ItemData(varItem2)
rstEmpSkill.Update
End If
skipdups:
Next varItem2
Next varItem
MsgBox "Your selections have been processed..."