Function not understood

D

Dudley

I am trying to amend a macro in an invoicing database written by someone
else. The macro marks an invoice as paid. Following through the code I come to

Function InvoicePriceIncVAT(INum As Long) As Currency
InvoicePriceIncVAT = InvoiceTotal("Price inc VAT", INum)
End Function

InvoiceTotal is another function, and "Price inc VAT" is a field in the
current table, but I cannot find what Inum means.

Then:

Function InvoiceTotal(Key As String, INum As Long) As Currency
Dim ITotal
ITotal = DLookup("[Total " & Key & "]", "Invoice Total Prices",
"[Invoice Number]=" & INum & "")
If IsNull(ITotal) Then
InvoiceTotal = 0
Else
InvoiceTotal = ITotal
End If
End Function

"Invoice Total Prices" is the name of a query, and I would expect the name
of the relevant field in it, "Total Price inc VAT" - instead I find Total " &
Key &". "Invoice Number" is a field in the query, but why does it = INum?

Can anyone help or suggest where I should look to get a solution?

Thanks
Dudley
 
T

tina

Function InvoicePriceIncVAT(**INum** As Long) As Currency

there's your INum - it's the function argument. so when the function is
called, INum stores whatever value is passed to it in the calling statement.

hth
 
D

Dudley

Thanks for your help. Can you tell me where I can find out about function
arguments and calling statements? I could not find anything useful in VBA
Help.

Dudley

tina said:
Function InvoicePriceIncVAT(**INum** As Long) As Currency

there's your INum - it's the function argument. so when the function is
called, INum stores whatever value is passed to it in the calling statement.

hth


Dudley said:
I am trying to amend a macro in an invoicing database written by someone
else. The macro marks an invoice as paid. Following through the code I come to

Function InvoicePriceIncVAT(INum As Long) As Currency
InvoicePriceIncVAT = InvoiceTotal("Price inc VAT", INum)
End Function

InvoiceTotal is another function, and "Price inc VAT" is a field in the
current table, but I cannot find what Inum means.

Then:

Function InvoiceTotal(Key As String, INum As Long) As Currency
Dim ITotal
ITotal = DLookup("[Total " & Key & "]", "Invoice Total Prices",
"[Invoice Number]=" & INum & "")
If IsNull(ITotal) Then
InvoiceTotal = 0
Else
InvoiceTotal = ITotal
End If
End Function

"Invoice Total Prices" is the name of a query, and I would expect the name
of the relevant field in it, "Total Price inc VAT" - instead I find Total " &
Key &". "Invoice Number" is a field in the query, but why does it = INum?

Can anyone help or suggest where I should look to get a solution?

Thanks
Dudley
 
T

tina

a function argument is...like a box or bin in which you place a value, so
that the value can be used by the code in the function. it usually has a
specific data type, to help you put the right kind of value into it. for
instance, take a look at the DateDiff Function topic in Access Help. it has
5 arguments - 3 required and 2 optional. if you want to find out how many
days are between 1/1/2006 and today, you have to place those specific values
in the arguments:

DateDiff("d", #1/1/2006#, Date())

the DateDiff() function is a built-in function in Access. you can also write
custom functions, with or without arguments as needed, and call them from
within a module, and also in expressions in queries, forms, reports, macros,
and modules. the code you posted gives a good example of a function with an
argument:

InvoicePriceIncVAT(INum As Long)

that includes code that calls another function with arguments:

InvoiceTotal("Price inc VAT", INum)

hth


Dudley said:
Thanks for your help. Can you tell me where I can find out about function
arguments and calling statements? I could not find anything useful in VBA
Help.

Dudley

tina said:
Function InvoicePriceIncVAT(**INum** As Long) As Currency

there's your INum - it's the function argument. so when the function is
called, INum stores whatever value is passed to it in the calling statement.

hth


Dudley said:
I am trying to amend a macro in an invoicing database written by someone
else. The macro marks an invoice as paid. Following through the code I come to

Function InvoicePriceIncVAT(INum As Long) As Currency
InvoicePriceIncVAT = InvoiceTotal("Price inc VAT", INum)
End Function

InvoiceTotal is another function, and "Price inc VAT" is a field in the
current table, but I cannot find what Inum means.

Then:

Function InvoiceTotal(Key As String, INum As Long) As Currency
Dim ITotal
ITotal = DLookup("[Total " & Key & "]", "Invoice Total Prices",
"[Invoice Number]=" & INum & "")
If IsNull(ITotal) Then
InvoiceTotal = 0
Else
InvoiceTotal = ITotal
End If
End Function

"Invoice Total Prices" is the name of a query, and I would expect the name
of the relevant field in it, "Total Price inc VAT" - instead I find
Total
" &
Key &". "Invoice Number" is a field in the query, but why does it = INum?

Can anyone help or suggest where I should look to get a solution?

Thanks
Dudley
 

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

Similar Threads


Top