Data type mismatch in criteria expression (1 Viewer)

DDivney

Registered User.
Local time
Today, 03:35
Joined
Jul 17, 2012
Messages
12
I'm trying to make a cascading combo box, but the afterupdate event that updates the rowsource of the other combo box throws up this error. Basically, I have two fields, TournamentID and Home (as in home team). The rowsource for the TournamentID combo box is as follows

Code:
SELECT [Tournament].[TournamentID], [Tournament].[TournamentName] FROM Tournament;

And its after update event is:

Code:
Me.Home.RowSource = "SELECT Team.TeamID, Team.TeamName, Team.TournamentID " & _
"FROM Team " & _
"WHERE Team.TournamentID = '" & Me.TournamentID.Column(0) & "' " & _
"ORDER BY Team.TeamName; "

I've checked the data types and they're fine. Could this be some sort of referencing error?
 

John Big Booty

AWF VIP
Local time
Today, 19:35
Joined
Aug 29, 2005
Messages
8,263
If the field TournamentID is a numeric field then you do not need the inverted commas, and you code should look like;
Code:
Me.Home.RowSource = "SELECT Team.TeamID, Team.TeamName, Team.TournamentID " & _
"FROM Team " & _
"WHERE Team.TournamentID = " & Me.TournamentID.Column(0) & _
"ORDER BY Team.TeamName; "
 

DDivney

Registered User.
Local time
Today, 03:35
Joined
Jul 17, 2012
Messages
12
That worked very well, thank you! I'm still learning on the fly, which is quite awful really... What do the inverted commas denote then?
 

John Big Booty

AWF VIP
Local time
Today, 19:35
Joined
Aug 29, 2005
Messages
8,263
You require the inverted commas for String fields and a Date field must be enclosed between hash marks (#).
 

Users who are viewing this thread

Top Bottom