Good morning, I am trying to convert from Access 2007 to 2010 and I am getting this error "Compile Error User-defined type not defined. Please help Thanks!
Private Sub cmdAppend_Click()
Dim cnn1 As ADODB.Connection
Set cnn1 = CurrentProject.Connection
'set up the recordset
Dim myRSQuotes As New ADODB.Recordset
myRSQuotes.ActiveConnection = cnn1
'variables for the work required
Dim ctl1 As Control
Dim lngloop1 As Long
'variables for the subcontractors
Dim ctl2 As Control
Dim lngloop2 As Long
'variable to hold the contractors for form filtering
Dim strIDs As String
'open the recordset based on the tblSubcontractorQuotes table
myRSQuotes.Open "tblSubcontractorQuotes", , adOpenDynamic, adLockOptimistic
'set the controls to the work required list or subcontractor list
Set ctl1 = Me.lstWorkReq 'work required control
Set ctl2 = Me.lstSubs 'subcontractor control
'check to make sure at least 1 required work item has been selected otherwise return message
If ctl1.ItemsSelected.Count = 0 Then
MsgBox "You must select at least one required work item from the list"
ctl1.SetFocus
Exit Sub
End If
'check to make sure at least 1 required subcontractor has been selected otherwise return message
If ctl2.ItemsSelected.Count = 0 Then
MsgBox "You must select at least one subcontractor from the list"
ctl2.SetFocus
Exit Sub
End If
'for each selected work, add the subcontractors to the tblSubcontractorQuotes table via the recordset
For lngloop1 = 0 To ctl1.ItemsSelected.Count - 1
For lngloop2 = 0 To ctl2.ItemsSelected.Count - 1
'store the IDs of the subcontractors
If ctl2.ItemsSelected.Count = 1 Then
strIDs = ctl2.ItemData(ctl2.ItemsSelected(lngloop2))
Else
If lngloop2 = 0 Then
strIDs = strIDs & ctl2.ItemData(ctl2.ItemsSelected(lngloop2))
Else
strIDs = strIDs + "," & ctl2.ItemData(ctl2.ItemsSelected(lngloop2))
End If
End If
If DCount("*", "tblSubcontractorQuotes", "fkCompanyID=" & ctl2.ItemData(ctl2.ItemsSelected(lngloop2)) & " AND fkworkrequiredID=" & ctl1.ItemData(ctl1.ItemsSelected(lngloop1))) = 0 Then
With myRSQuotes
.AddNew
!fkCompanyID = ctl2.ItemData(ctl2.ItemsSelected(lngloop2))
!fkworkrequiredID = ctl1.ItemData(ctl1.ItemsSelected(lngloop1))
.Update
End With
End If
Next lngloop2
Next lngloop1
myRSQuotes.Close
Set myRSQuotes = Nothing
Set ctl1 = Nothing
Set ctl2 = Nothing
MsgBox "Proceed to the Next Screen to Enter Quotes"
'Debug.Print strIDs
DoCmd.OpenForm "frmSubcontractors", acNormal, , "pkCompanyID in (" & strIDs & ")"
End Sub
Private Sub cmdAppend_Click()
Dim cnn1 As ADODB.Connection
Set cnn1 = CurrentProject.Connection
'set up the recordset
Dim myRSQuotes As New ADODB.Recordset
myRSQuotes.ActiveConnection = cnn1
'variables for the work required
Dim ctl1 As Control
Dim lngloop1 As Long
'variables for the subcontractors
Dim ctl2 As Control
Dim lngloop2 As Long
'variable to hold the contractors for form filtering
Dim strIDs As String
'open the recordset based on the tblSubcontractorQuotes table
myRSQuotes.Open "tblSubcontractorQuotes", , adOpenDynamic, adLockOptimistic
'set the controls to the work required list or subcontractor list
Set ctl1 = Me.lstWorkReq 'work required control
Set ctl2 = Me.lstSubs 'subcontractor control
'check to make sure at least 1 required work item has been selected otherwise return message
If ctl1.ItemsSelected.Count = 0 Then
MsgBox "You must select at least one required work item from the list"
ctl1.SetFocus
Exit Sub
End If
'check to make sure at least 1 required subcontractor has been selected otherwise return message
If ctl2.ItemsSelected.Count = 0 Then
MsgBox "You must select at least one subcontractor from the list"
ctl2.SetFocus
Exit Sub
End If
'for each selected work, add the subcontractors to the tblSubcontractorQuotes table via the recordset
For lngloop1 = 0 To ctl1.ItemsSelected.Count - 1
For lngloop2 = 0 To ctl2.ItemsSelected.Count - 1
'store the IDs of the subcontractors
If ctl2.ItemsSelected.Count = 1 Then
strIDs = ctl2.ItemData(ctl2.ItemsSelected(lngloop2))
Else
If lngloop2 = 0 Then
strIDs = strIDs & ctl2.ItemData(ctl2.ItemsSelected(lngloop2))
Else
strIDs = strIDs + "," & ctl2.ItemData(ctl2.ItemsSelected(lngloop2))
End If
End If
If DCount("*", "tblSubcontractorQuotes", "fkCompanyID=" & ctl2.ItemData(ctl2.ItemsSelected(lngloop2)) & " AND fkworkrequiredID=" & ctl1.ItemData(ctl1.ItemsSelected(lngloop1))) = 0 Then
With myRSQuotes
.AddNew
!fkCompanyID = ctl2.ItemData(ctl2.ItemsSelected(lngloop2))
!fkworkrequiredID = ctl1.ItemData(ctl1.ItemsSelected(lngloop1))
.Update
End With
End If
Next lngloop2
Next lngloop1
myRSQuotes.Close
Set myRSQuotes = Nothing
Set ctl1 = Nothing
Set ctl2 = Nothing
MsgBox "Proceed to the Next Screen to Enter Quotes"
'Debug.Print strIDs
DoCmd.OpenForm "frmSubcontractors", acNormal, , "pkCompanyID in (" & strIDs & ")"
End Sub