Hi all
I have been scouring this forum and many others for a solution to this issue, and while they've helped enormously I still can't resolve my problem. I'm sort of loathed to ask as I think it's a simple problem.
I am using this code to count the number of records that meet a couple of criteria in a table. The variables are gathered from a form. All variable are string variable in the tables and on the form.
Code:
ConfigCount = DCount("[MachineNo]", "[tblMachineConfigurations]", "[MachineNo] = '" & Me.cmbMachineNo & "' And [CustomerID] = " & "'Me.txtCurrentOwnerNo'")
Debug.Print ConfigCount
The problem is that the statement is returning 0, when I know that (in testing) there are records that meet the criteria, so should be returning a 1.
If I hard code the variables like this, I get the correct result;
Code:
ConfigCount = DCount("[MachineNo]", "tblMachineConfigurations", "[MachineNo] = '1215-1490' And [CustomerID] = '3361'")
Debug.Print ConfigCount
I've been going around in circles with this and would appreciate any insights in to what I am doing wrong.
As an aside I've been reading that the function may not work if there are no records that meet the criteria because DCount doesn't count Null values. Is that correct?