I have a table 'tblContacts'. It has what you would expect to find with regards to fields in a contact db. It includes the [ID] field as well as a [CompanyLogo] field that looks up the value from a table called 'tblCompanyProfiles'
I am attempting what I would think is a very simple lookup to search the tblContacts, locating the contact ID I want and then returning the value in field [CompanyLogo].
No matter what I have tried, it seems to always result in a null value. I can confirm that the contact ID that I am using is valid and it has data in [CompanyLogo].
My tired eyes would appreciate your help.
Code:
Private Sub Command56_Click()
Dim companyID As Variant
Dim ownerID As Long
On Error GoTo Command56_Click_Err
On Error Resume Next
If (Form.Dirty) Then
DoCmd.RunCommand acCmdSaveRecord
End If
If (MacroError.Number <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
Exit Sub
End If
If (Form.NewRecord) Then
Beep
Exit Sub
End If
ownerID = Me.Owner.Value ' From the current form and is a number
MsgBox "ownerID " & ownerID ' I get the correct value here.
companyID = DLookup("First Name", "tblContacts", "ID = " & ownerID) ' I have attempted numerous variations of this statement, but it always returns nothing.
MsgBox "companyID " & companyID
Command56_Click_Exit:
Exit Sub
Command56_Click_Err:
MsgBox Error$
Resume Command56_Click_Exit
End Sub