Criteria problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can anyone help with a criteria problem

Using :

Dim curX As Currency
curX = DSum("[BudgetTotal]", "Tblbudgets", "[BudgetId] = " & Me.BudgetFromId)

Which gives me the result I need.

I need to do add another criteria which is causing the problem.

What I have tried is :

curX = DSum("[BudgetTotal]", "Tblbudgets", "[BudgetId] = " & Me.BudgetFromId
And “[budgetperiodID] = “ & Me.budgetperiodID)

but this does not work and comes back with a ‘type mismatch’ error.
 
The 'and' should be inside the quotes ...

curX = DSum("[BudgetTotal]", "Tblbudgets", "[BudgetId] = " & Me.BudgetFromId
& " And [budgetperiodID] = " & Me.budgetperiodID)
 
Solved it straight away - many thanks Brendon

Paul

Brendan Reynolds said:
The 'and' should be inside the quotes ...

curX = DSum("[BudgetTotal]", "Tblbudgets", "[BudgetId] = " & Me.BudgetFromId
& " And [budgetperiodID] = " & Me.budgetperiodID)

--
Brendan Reynolds (MVP)


Paul said:
Can anyone help with a criteria problem

Using :

Dim curX As Currency
curX = DSum("[BudgetTotal]", "Tblbudgets", "[BudgetId] = " &
Me.BudgetFromId)

Which gives me the result I need.

I need to do add another criteria which is causing the problem.

What I have tried is :

curX = DSum("[BudgetTotal]", "Tblbudgets", "[BudgetId] = " &
Me.BudgetFromId
And "[budgetperiodID] = " & Me.budgetperiodID)

but this does not work and comes back with a 'type mismatch' error.
 
If [budgetperiodID] is a numeric field:
curX = DSum("[BudgetTotal]", "Tblbudgets", "[BudgetId] = " & Me.BudgetFromId _
& " And “ & [budgetperiodID] = “ & Me.budgetperiodID)

If [budgetperiodID] is tex field:
curX = DSum("[BudgetTotal]", "Tblbudgets", "[BudgetId] = " & Me.BudgetFromId _
& " And “ & [budgetperiodID] = '“ & Me.budgetperiodID & "'")
 
The AND needs to be encapsulated in quotes as in

curX = DSum("[BudgetTotal]", "Tblbudgets", "[BudgetId] = " &
Me.BudgetFromId And “[budgetperiodID] = “ & Me.budgetperiodID)
--------

Should be...

curX = DSum("[BudgetTotal]", "Tblbudgets", "[BudgetId] = " &
Me.BudgetFromId & " And [budgetperiodID] = “ & Me.budgetperiodID)
 
Back
Top