timekeepr9
Programmer
Hi,
I have 2 relevant tables, one with a list of students, and one with a list of incidents regarding students. The student's primary key is the incident table's foreign key. I have a form where the user can basically create a query through combo boxes to create a report with the selected info.
Everything works perfectly except for the student name. I have a combo box w/ the bound key being the primary key. In the on click method of the build report button, I build up a WITH sql statement and then open a report w/ the WITH statement. It's basically just a lot of if statements checking if the box is blank or not, and then doing the appropriate statement. When I try to compare the student (primary key) to the foreign key of the incident table; however, it pops up a box saying "Enter parameter value: Points Sheet Table - 1 per date.Foreign Key" which I think means its not finding the foreign key. However, the field is definitly called foreign key and is definitly in that table. If I change foreign key to some other number field it works perfectly.
I tried changing the name of foreign key to something else, but no dice. Anyone have any thoughts why this wouldn't work? Here is part of the block of code:
The notes works fine, by the student fails. It creates the following sql substatement:
[Points Sheet Table - 1 per date].[Foreign Key] = 189
Anyone have any thoughts? Thanks!
I have 2 relevant tables, one with a list of students, and one with a list of incidents regarding students. The student's primary key is the incident table's foreign key. I have a form where the user can basically create a query through combo boxes to create a report with the selected info.
Everything works perfectly except for the student name. I have a combo box w/ the bound key being the primary key. In the on click method of the build report button, I build up a WITH sql statement and then open a report w/ the WITH statement. It's basically just a lot of if statements checking if the box is blank or not, and then doing the appropriate statement. When I try to compare the student (primary key) to the foreign key of the incident table; however, it pops up a box saying "Enter parameter value: Points Sheet Table - 1 per date.Foreign Key" which I think means its not finding the foreign key. However, the field is definitly called foreign key and is definitly in that table. If I change foreign key to some other number field it works perfectly.
I tried changing the name of foreign key to something else, but no dice. Anyone have any thoughts why this wouldn't work? Here is part of the block of code:
Code:
If Me!student <> "" Then
whereString = whereString & stringAnd & "[Points Sheet Table - 1 per date].[Foreign Key] = " & Me!student
End If
If (Len(whereString) > 0) Then stringAnd = " AND "
If Me!Notes <> "" Then
whereString = whereString & stringAnd & "[Points Sheet Table - 1 per date].[notes] LIKE '*" & Me!Notes & "*'"
End If
The notes works fine, by the student fails. It creates the following sql substatement:
[Points Sheet Table - 1 per date].[Foreign Key] = 189
Anyone have any thoughts? Thanks!