HELP! Dlookup ()

bobby

Registered User.
Local time
Today, 23:21
Joined
Apr 29, 2004
Messages
28
Guys, im trying to use a Dlookup to get the unique id (integer) from a table.

Im doing a query, to put the result into a textbox.

Dlookup("[Match_ID]", "[tblMatch]",
"Home_Club_ID = [Forms]![frmAdd_Result].[cboHomeTeams] AND Away_Club_ID = [Forms]![frmAdd_Result].[cboAwayTeams]");

So basically,

Form1: HomeTeam
Form1: AwayTeam

On form 2 i need to get the matchID of the record that has the same hometeam and away team that is being displayed on form1.

The hometeam and away teams are in combo boxes.

Im not sure if Dlookup is the correct function to use but if anyone can help, i would really appreciate it
 
Put this in the Control Source of the text box on form2:

=DLookUp("[Match_ID]","[tblMatch]","Home_Club_ID =" & [Forms]![frmAdd_Result]![cboHomeTeams] & " AND Away_Club_ID = " & [Forms]![frmAdd_Result]![cboAwayTeams])


If Home_Club_ID and Away_Club_ID are text fields, there values need to be surrounded by quotes i.e.

=DLookUp("[Match_ID]","[tblMatch]","Home_Club_ID ='" & [Forms]![frmAdd_Result]![cboHomeTeams] & "' AND Away_Club_ID = '" & [Forms]![frmAdd_Result]![cboAwayTeams] & "'")
 
I get an error when doing this :

=DLookUp("[Match_ID]","[tblMatch]","Home_Club_ID ='" & Forms!frmAdd_Result!cboHomeTeams & "' AND Away_Club_ID = '" & Forms!frmAdd_Result!cboAwayTeams & "'")

The text box just shows up "#error".

When i try to start form 2 manually instead of having it opened from a form1 button, i get the error :

"The expression is typed incorrectly, or it is too complex to be evaluated"
 
I tried the one that was made for fields that arnt of type text and that worked, ty. Hopefully i shouldnt have too many more problems. Thanks !
 

Users who are viewing this thread

Back
Top Bottom