Is it possible to get VBA constant values into a report

  • Thread starter graeme34 via AccessMonster.com
  • Start date
G

graeme34 via AccessMonster.com

Hi
If this is a stupid question you'll have to forgive me, still a Learner! :)

Is it possible to get VBA constant values into a report?
Or do I have to do the calculations in code first. I have an Invoice report
that has a subreport (details). The control source for the subreport is the
following query:

SELECT tblDespatchLine.[Despatch Number], tblDespatchLine.[Quantity Sent],
tblSalesOrderLine.[Product Code], tblProduct.Description, tblSalesOrderLine.
Price, [Quantity Sent]*[Price] AS [Line Total], tblSalesOrderLine.VATRate
FROM tblProduct INNER JOIN (tblDespatchLine INNER JOIN tblSalesOrderLine ON
tblDespatchLine.[Product Code]=tblSalesOrderLine.[Product Code]) ON
(tblDespatchLine.[Product Code]=tblProduct.[Product Code]) AND (tblProduct.
[Product Code]=tblSalesOrderLine.[Product Code]);

Where VATRate is a Value either A, B or C.
I then have VBA constants in my declarations:

Public Const conVATA = 0.175
Public Const conVATB = 0.08
Public Const conVATC = 0

I dont suppose theres a way of getting the constants into the report??

Thank you in advance
Graeme.
 
A

Allen Browne

The report cannot read the constants.

You could create a function to retrieve the constant, e.g.:
Function GetVATA() As Double
GetVATA = conVATA
End Function
and you can then use the function in the Control Source of a text box, e.g.:
=GetVATA()

Or, it might be better to put the values in a table and use DLookup() to
read them from there.
 
G

graeme34 via AccessMonster.com

Thank you Allen

I thought as much, but it was worth a try :)

Appreciate the function idea I will probably use that.

Allen said:
The report cannot read the constants.

You could create a function to retrieve the constant, e.g.:
Function GetVATA() As Double
GetVATA = conVATA
End Function
and you can then use the function in the Control Source of a text box, e.g.:
=GetVATA()

Or, it might be better to put the values in a table and use DLookup() to
read them from there.
Hi
If this is a stupid question you'll have to forgive me, still a Learner!
[quoted text clipped - 29 lines]
Thank you in advance
Graeme.
 

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