Not2ruthless
asked on
vba DCount with 2 criteria
Hello,
I have created an unbound form called "frmAddTrainClasses". On it I have a text field, "StudentID", and a ComboBox named "Class1" that obtains values from another table named tblClasses.
I am trying to count, via VBA, how many referrals in another qry that include BOTH the same StudentID AND ClassID. It took me FOREVER to not get syntax errors but now am receiving TypeMisMatch errors. I would appreciate any help. Here it is below:
Private Sub ViewClass1_Click()
Dim ClassValue
If IsNull(Class1.Column(0)) = False Then
Let ClassValue = Class1.Column(0) 'this is reporting correctly
If DCount("[ReferralID]", "qryAllReferrals", "[StudentID] = " & Me![StudentID] And "[ClassID] = " & ClassValue) > 0 Then
blah
else
blah blah
endif
endif
I have created an unbound form called "frmAddTrainClasses". On it I have a text field, "StudentID", and a ComboBox named "Class1" that obtains values from another table named tblClasses.
I am trying to count, via VBA, how many referrals in another qry that include BOTH the same StudentID AND ClassID. It took me FOREVER to not get syntax errors but now am receiving TypeMisMatch errors. I would appreciate any help. Here it is below:
Private Sub ViewClass1_Click()
Dim ClassValue
If IsNull(Class1.Column(0)) = False Then
Let ClassValue = Class1.Column(0) 'this is reporting correctly
If DCount("[ReferralID]", "qryAllReferrals", "[StudentID] = " & Me![StudentID] And "[ClassID] = " & ClassValue) > 0 Then
blah
else
blah blah
endif
endif
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER