both tables have a primary key. i was told i may need some code and i subed out some work last night and the guys code still dont work i am now getting a compile error "user-defined type not defined"
Private Sub Phone_Seeker_Click()
On Error GoTo Error_ME2
Dim aCCNT2 As String, phonesee As String, accnt56 As String
phonesee = InputBox("Please enter a phone number...", "PN CREDIT SERVICES V7.6", "000-000-0000")
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim intResult As Integer
Dim strSQL As String
Dim mostLikely As String
Dim strSQL2 As String
Dim strWhere As String
Set db = CurrentDb
strSQL = "SELECT Count(T_Phones.Account_Num) AS FoneCount, T_Phones.Account_Num As soughtAccnt"
strSQL = strSQL & " FROM T_Phones WHERE (((T_Phones.Phone)='" & phonesee & "')) GROUP BY T_Phones.Account_Num ORDER BY Count(T_Phones.Account_Num) DESC;"
strSQL2 = ""
strWhere = ""
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
If rs.RecordCount <> 0 Then
Do Until rs.EOF
intResult = rs("FoneCount")
mostLikely = rs("soughtAccnt")
strWhere = strWhere & "((Account_Num)='" & mostLikely & "') Or "
rs.MoveNext
Loop
rs.Close
db.Close
strWhere = Left(strWhere, Len(strWhere) - 4)
If (intResult = 1) Then
DoCmd.OpenForm "F_Q_T_Collection_Records_Phone_Search", , , "Account_Num = '" & mostLikely & "'"
ElseIf (intResult > 1) Then
MsgBox "Phone number found on multiple accounts!" & vbCrLf, vbOKOnly, "PN CREDIT SERVICES V7.6"
DoCmd.OpenForm "F_Q_T_Collection_Records_Phone_Search", , , , acFormEdit
strSQL2 = "SELECT * FROM T_Collection_Records "
strSQL2 = strSQL2 & "WHERE ("
strSQL2 = strSQL2 & strWhere
strSQL2 = strSQL2 & ");"
Forms!F_Q_T_Collection_Records_Phone_Search.RecordSource = strSQL2
Else
MsgBox "Phone number not found!" & vbCrLf, vbOKOnly, "PN CREDIT SERVICES V7.6"
End If
End If
Exit_Point:
Exit Sub
Error_ME2:
Resume Exit_Point
End Sub