Get an array from a function

P

Phil

I am trying to get a number of let's say invoice numbers for a given client
depending on the amount paid. I have a query that lists all the invoice
numbers and the various combinations of invoice numbers and their totals. I
now want to say find which invoices for Fred add up to £100

In a function in a normal module I have

Private Type InvoiceIDArray
InvoiceIDs(10) As Long
End Type

Function GetInvoiceIDs(MemID As Long, FeePaid As Currency) As SpaceIDArray

Dim MyDb As Database
Dim StoragePaidSet As Recordset

etc
End Function

Compiles OK but if I type "getInvoiceids(1,100) into the immediate window I
get an error "Compile Error User-Defined type not defined"

What am I doing wrong


Function GetInvoiceIDs(MemID As Long, FeePaid As Currency) As Long()

again compiles OK but gives me a "Compile Error Type mismatch"

Thanks for any advise

Phil
 
M

mie via AccessMonster.com

Phil said:
I am trying to get a number of let's say invoice numbers for a given client
depending on the amount paid. I have a query that lists all the invoice
numbers and the various combinations of invoice numbers and their totals. I
now want to say find which invoices for Fred add up to £100

In a function in a normal module I have

Private Type InvoiceIDArray
InvoiceIDs(10) As Long
End Type

Function GetInvoiceIDs(MemID As Long, FeePaid As Currency) As SpaceIDArray

Dim MyDb As Database
Dim StoragePaidSet As Recordset

etc
End Function

Compiles OK but if I type "getInvoiceids(1,100) into the immediate window I
get an error "Compile Error User-Defined type not defined"

What am I doing wrong

Function GetInvoiceIDs(MemID As Long, FeePaid As Currency) As Long()
'--Typo? or try change to:
Function GetInvoiceIDs(MemID As Long, FeePaid As Currency) As Long
 
A

Alex Dybenko

hi,
this works at me:
Public Type InvoiceIDArray
InvoiceIDs(10) As Long
End Type

Function GetInvoiceIDs(MemID As Long, FeePaid As Currency) As InvoiceIDArray
Dim a As InvoiceIDArray
a.InvoiceIDs(0) = 1
GetInvoiceIDs = a
End Function

?GetInvoiceIDs(1,2).InvoiceIDs(0)
1

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com
 
P

Phil

Public Type InvoiceIDArray
InvoiceIDs(10) As Long
End Type

Function GetInvoiceIDs(MemID As Long, FeePaid As Currency) As
InvoiceIDArray Dim a As InvoiceIDArray
a.InvoiceIDs(0) 1
GetInvoiceIDs a
End Function

Thanks Alex, Couldn't get your function to compile (AK2) but it put me on the
right track. I was typing "getInvoiceids(1,100)" instead of your version of
"GetInvoiceIDs(1,2).InvoiceIDs(0)". That's why I was getting the mismatch
errors

Thanks again

Phil
 
Top