Code:
Dim rs As DAO.Recordset
Dim strSQL As String
TextOwnerFullName = vbNullString
strSQL = "SELECT [OwnerFirstName] & ' ' & [OwnerLastName] AS OwnerFullName " _
& "FROM tblOwner INNER JOIN tblProductInfo ON tblOwner.OwnerID = tblProductInfo.OwnerID " _
& "WHERE ((tblProductInfo.Productname)='" & [Forms]![frmAdminShowRecords]![ComboProductName].Column(1) & "' " _
& "AND ((tblOwner.DomainID)=" & [Forms]![frmAdminShowRecords]![Domain Name] & "));"
Debug.Print strSQL
Set rs = CurrentDb.OpenRecordset(strSQL)
If rs.RecordCount = 0 Then
MsgBox "Either no Product or no domain match"
Exit Sub
End If
rs.MoveLast
rs.MoveFirst
Me.TextOwnerFullName = rs!OwnerFullName
Set rs = Nothing
End Sub
Got rid of the "too few parameters" with changes to sql above.
The debug.print should show something like:
SELECT [OwnerFirstName] & ' ' & [OwnerLastName] AS OwnerFullName FROM tblOwner INNER JOIN tblProductInfo ON tblOwner.OwnerID = tblProductInfo.OwnerID WHERE ((tblProductInfo.Productname)='Whistle' AND ((tblOwner.DomainID)=1));
The red is the values pulled from the form.
I had to make some assumptions on your form and data.
The ComboProductName.Column(1) assumes that the rowsource for that combobox is
Code:
SELECT ID, [ProductName] FROM tblProductInfo;
Also, since I don't know your form, I couldn't determine which event to attach the code to. Just for testing I used FORM_CURRENT.
If still problems, best way to resolve is to post DB here.