Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Macros / January 2006

Tip: Looking for answers? Try searching our database.

Function not understood

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dudley - 25 Jan 2006 17:25 GMT
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
tina - 25 Jan 2006 17:43 GMT
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

> 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
[quoted text clipped - 27 lines]
> Thanks
> Dudley
Dudley - 27 Jan 2006 12:25 GMT
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

> Function InvoicePriceIncVAT(**INum** As Long) As Currency
>
[quoted text clipped - 36 lines]
> > Thanks
> > Dudley
tina - 28 Jan 2006 05:23 GMT
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

> 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
[quoted text clipped - 42 lines]
> > > Thanks
> > > Dudley
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.