Z
Zikar
Hi Team,
I am trying to call the following SQL Query from within the Code to return
the count of records that meet a criteria where a field value in the Table
would be equal to the Value of a Control that is within a Subform:
Dim rst As Recordset
Dim SQL As String
SQL = "SELECT
Count(Tbl_Risk_LocalProfiles_ResponsiblePersons.RiskResponsiblePersonRecordID) AS COUNTER " & _
"FROM Tbl_Risk_LocalProfiles_Subform INNER JOIN
Tbl_Risk_LocalProfiles_ResponsiblePersons ON
Tbl_Risk_LocalProfiles_Subform.ProfileUpdate_ID =
Tbl_Risk_LocalProfiles_ResponsiblePersons.ProfileUpdate_ID " & _
"WHERE (((Tbl_Risk_LocalProfiles_ResponsiblePersons.ProfileUpdate_ID)>0) AND
((Tbl_Risk_LocalProfiles_ResponsiblePersons.ProfileUpdate_ID) =
Forms![Risk_ProfileUpdate_Subform].Form![txtProfileUpdate_ID]));"
Set rst = CurrentDb.OpenRecordset(SQL)
Me![NumOfRiskOwners] = rst![COUNTER]
Set rst = Nothing
When I run the code I get the Run-time error '3061':
Too few parameters, Expected 1.
However, when I substitute in the query code a field value which is equal to
the value of the Control in the Subform, in this case is written above as
Forms![Risk_ProfileUpdate_Subform].Form![txtProfileUpdate_ID], then the code
runs fine and returns the correct count number of records. I know my problem
lies in the method I am referencing the Control named txtProfileUpdate_ID in
the Subform which is a main feature for this procedure to work.
I would greatly appreciate if someone can provide me with help to resolve
this issue of correctly referencing the Control in the Subform.
Cheers!
I am trying to call the following SQL Query from within the Code to return
the count of records that meet a criteria where a field value in the Table
would be equal to the Value of a Control that is within a Subform:
Dim rst As Recordset
Dim SQL As String
SQL = "SELECT
Count(Tbl_Risk_LocalProfiles_ResponsiblePersons.RiskResponsiblePersonRecordID) AS COUNTER " & _
"FROM Tbl_Risk_LocalProfiles_Subform INNER JOIN
Tbl_Risk_LocalProfiles_ResponsiblePersons ON
Tbl_Risk_LocalProfiles_Subform.ProfileUpdate_ID =
Tbl_Risk_LocalProfiles_ResponsiblePersons.ProfileUpdate_ID " & _
"WHERE (((Tbl_Risk_LocalProfiles_ResponsiblePersons.ProfileUpdate_ID)>0) AND
((Tbl_Risk_LocalProfiles_ResponsiblePersons.ProfileUpdate_ID) =
Forms![Risk_ProfileUpdate_Subform].Form![txtProfileUpdate_ID]));"
Set rst = CurrentDb.OpenRecordset(SQL)
Me![NumOfRiskOwners] = rst![COUNTER]
Set rst = Nothing
When I run the code I get the Run-time error '3061':
Too few parameters, Expected 1.
However, when I substitute in the query code a field value which is equal to
the value of the Control in the Subform, in this case is written above as
Forms![Risk_ProfileUpdate_Subform].Form![txtProfileUpdate_ID], then the code
runs fine and returns the correct count number of records. I know my problem
lies in the method I am referencing the Control named txtProfileUpdate_ID in
the Subform which is a main feature for this procedure to work.
I would greatly appreciate if someone can provide me with help to resolve
this issue of correctly referencing the Control in the Subform.
Cheers!