using an excel database function in Visual Basic

T

TAD from DBL

How do I property invoke/use an excel database function like dsum in a visual
basic sub?

why can't I just set

x = dsum(tablerange,"fieldname",criterianame)

How do I declare this existing function? I am new to this.
 
S

Shasur

Hi

Can you try the following

x = Application.WorksheetFunction.DSum(tablerange, "fieldname", criterianame)

Cheers
Shasur
 
T

TAD from DBL

Shasur, it gives me an "object required error"

Thanks for your input!

Dim QueryArray(2) As Integer
Dim x As Integer
x = Application.WorksheetFunction.DSum(testtable, "Secondfield",
firstcriteria)
QueryArray(0) = 100
QueryArray(1) = x
QueryArray(2) = 500
Range("J28") = QueryArray(0)
Range("J29") = QueryArray(1)
Range("J30") = QueryArray(3)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top