Query Problem

paulkc

Board Regular
Joined
May 18, 2007
Messages
204
Office Version
  1. 365
I am trying to learn how to use Access 2007. I have a db set up that maintains some student information. I have a main table that pulls the student names from a student table. I am trying to create a query that filters the main table based on a particular student. I cannot seem to get the relationships set up correctly so that I can use the students name instead of the students ID (primary key on the Students table). If I use the students ID it works fine but it I use the students name (in quotes) I get a "Data type mismatch in criteria expression." message.

The relationships are set up as follows:
Main Table: StudentName Field is related to the Students Table: ID Field

I hope I have explained this well enough that someone can help me. I am sure I am missing something obvious, but I can't figure out what it is.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
In your query, you need to set up a relationship between the table that has the student names and the main table. Display the student name from the student name table in your query.
 
Upvote 0
I have tried relating the query to the Students table and it still wouldn't work. After your response, I tried relating the StudentName field in the query to the StudentName field in the Main table and also to the StudentName field in the Students Table. What am I missing?
 
Upvote 0
What is your PK for your student table and your FK in the Main table? These are what you should be linking your relationship on in the query.
 
Upvote 0
Ok, I figured out what I was doing wrong. Something you said triggered it. I was pulling the StudentName from the Main table but I should have been pulling it from the Students table. Once I changed that, it works just fine. Thanks.
 
Upvote 0

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,077
Latest member
Jocksteriom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top