Hello geeks!
I am grappling with the Query design view of Access 2013 for two days, day and night, in the following way :-(
It is a very simple Query, named "qryStudentsByClass" with a few fields, notably:
StudentID, StudentName, DoB, Age (Calculated field), and Class etc.
I have entered the Criteria for Class as "ClassName"
Within my Form, I have included the following VBA code:
' Just to try any of the following 3 statements, one by one, of course:
Testing:
and
Problem:
The problem is that when I run the program, Query still prompts for the ClassName, instead of receiving the value passed from the Form.
I have even tried including the following line of code in the Criteria line of the Query:
But, still the problem remains the same.
Would any geek kindly get me out of this mess! Salute in anticipation
I am grappling with the Query design view of Access 2013 for two days, day and night, in the following way :-(
It is a very simple Query, named "qryStudentsByClass" with a few fields, notably:
StudentID, StudentName, DoB, Age (Calculated field), and Class etc.
I have entered the Criteria for Class as "ClassName"
Within my Form, I have included the following VBA code:
Code:
strClass = Me.txtClass.Value
Set QryDef = CurrentDb.QueryDefs("qryStudentsByClass")
Code:
QryDef![ClassName] = strClass
QryDef.Parameters(0).Value = strClass
QryDef.Parameters("ClassName").Value = strClass
Code:
rptName = "rptStudentsByClass"
DoCmd.OpenReport reportName:=rptName, View:=acViewReport
strQrySql = QryDef.SQL
Reports(rptName).RecordSource = strQrySql
...
...
Code:
Debug.Print QryDef.Parameters.Count --- returns [COLOR=DarkRed][I]1[/I][/COLOR]
Code:
Debug.Print QryDef.Parameters(0).Name ---- correctly returns [COLOR=DarkRed][I]ClassName[/I][/COLOR]
The problem is that when I run the program, Query still prompts for the ClassName, instead of receiving the value passed from the Form.
I have even tried including the following line of code in the Criteria line of the Query:
Code:
[Forms]![frmStudentsRpt]![txtClass] ------ with/without = sign.
Would any geek kindly get me out of this mess! Salute in anticipation
