Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use Recordset in Function 1

Status
Not open for further replies.

TimTDP

Technical User
Feb 15, 2004
373
ZA
In Access 2000, I have created the following function:
Function ComparePrices(AgencyID As Integer, _
ImportOrganisationId As Integer, _
CifOrFob As String)

I want to call the function using the result of a recordset like this:
ComparePrices 1,2,[rstCosting]![CostingType]

When I compile the code I get the error "Argument not optional".

What am I doing wrong?
 
Could be that functions return values and you are not providing a place to receive the value
Code:
[red]myValue = [/red]ComparePrices [red]([/red]1,2,[rstCosting]![CostingType][red])[/red]
You should also be explicit about what type of variable should be returned by the function
Code:
Function ComparePrices(AgencyID As Integer, _
                       ImportOrganisationId As Integer, _
                       CifOrFob As String)[red] As ????[/red]
As it stands, your function will return a variant.
 
Could it be that in some cases
"[rstCosting]![CostingType]" evaluates to a null?

IrishJim [pipe]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top