Hi,
When you say "my IDs are text" are you referring to the primary key of the table?
As a general design principle it is best to keep the primary key of the table as a autonumber field, that will uniquely identify each record.
When you link to another table (say between students and studentclasses using the StudentID) this is most efficient when linking a number. If you link using a text field Access will be slower linking the two tables together. Not a problem for small numbers of records, but for larger databases this will become significant.
In the example form I helped modify the line which generates the criteria for the subform is this:
If your class ID is a text string, and assuming the classID is in the first column of the listbox, then you would need to change this to:
To enclose a text string in your query definition you need to enclose it in single or double quotation marks. I have highlighted the single quotation marks above in red so you can see.
To summarise the best fix would be to change the ID from text to number, but as a temporary fix using quotation marks in the SQL code should work.
When you say "my IDs are text" are you referring to the primary key of the table?
As a general design principle it is best to keep the primary key of the table as a autonumber field, that will uniquely identify each record.
When you link to another table (say between students and studentclasses using the StudentID) this is most efficient when linking a number. If you link using a text field Access will be slower linking the two tables together. Not a problem for small numbers of records, but for larger databases this will become significant.
In the example form I helped modify the line which generates the criteria for the subform is this:
Code:
strFilter = strFilter & "tblClasses.ClassID=" & .Column(0, I)
If your class ID is a text string, and assuming the classID is in the first column of the listbox, then you would need to change this to:
Code:
strFilter = strFilter & "tblClasses.ClassID=[COLOR=Red]'[/COLOR]" & .Column(0, I) & "[COLOR=Red]'[/COLOR]"
To enclose a text string in your query definition you need to enclose it in single or double quotation marks. I have highlighted the single quotation marks above in red so you can see.
To summarise the best fix would be to change the ID from text to number, but as a temporary fix using quotation marks in the SQL code should work.