By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,220 Members | 1,095 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,220 IT Pros & Developers. It's quick & easy.

looking for a tutorial or detailed infos on how to work with arrays??

P: n/a


Nov 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Arrays? For a database application?

What do you think you want to do with them?

--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #2

P: n/a
Instead of using an array consider creating your own variable type:
VBA (Access 95 onwards) allows you to return an entire structure of values.
In database terms, this is analogous to returning an entire record rather
than a single field. For example, imagine an accounting database that needs
to summarize income by the categories Wages, Dividends, and Other. VBA
allows you to declare a user-defined type to handle this structure:

Public Type Income
Wages As Currency
Dividends As Currency
Other As Currency
Total As Currency
End TypeYou can now use this structure as the return type for a
function. In a real situation, the function would look up your database
tables to get the values, but the return values would be assigned like this:

Function GetIncome() As Income
GetIncome.Wages = 950
GetIncome.Dividends = 570
GetIncome.Other = 52
GetIncome.Total = GetIncome.Wages + GetIncome.Dividends +
GetIncome.Other
End FunctionTo use the function, you could type into the Immediate
Window:

? GetIncome().Wagesor you could include a text box on a report and set
its ControlSource property to:

= GetIncome().Total(Note: the use of "Public" in the Type declaration
gives it sufficient scope.)

Programmers with a background in C will instantly recognize the
possibilities now that user-defined types can be returned from functions. If
you're keen, user-defined types can even be based on other user-defined
types.
"Norman Fritag" <mt*****@ozemail.com.au> wrote in message
news:%w****************@nnrp1.ozemail.com.au...

Nov 12 '05 #3

P: n/a
r0adh0g wrote:
Instead of using an array consider creating your own variable type:
VBA (Access 95 onwards) allows you to return an entire structure of values. Programmers with a background in C will instantly recognize the
possibilities now that user-defined types can be returned from functions. If
you're keen, user-defined types can even be based on other user-defined
types.


Aha. And programmers with C++ knowledge may even creating Class modules,
extending the type with functions, procedures and properties.

That is definately true, but it depends quite a bit on what you want to
accomplish whether this will do much good. Code needs maintenance. Yes,
SQL code needs maintenance too.
--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #4

P: n/a
rkc

"r0adh0g" <ro*****@nospam.phreaker.net> wrote in message
news:40********@news.binaries.net...
Instead of using an array consider creating your own variable type:
VBA (Access 95 onwards) allows you to return an entire structure of values. In database terms, this is analogous to returning an entire record rather
than a single field. For example, imagine an accounting database that needs to summarize income by the categories Wages, Dividends, and Other. VBA
allows you to declare a user-defined type to handle this structure:

Public Type Income
Wages As Currency
Dividends As Currency
Other As Currency
Total As Currency
End


If you were to want to work with multiple instances of a udt learning about
arrays or even collections would be a valid goal.


Nov 12 '05 #5

P: n/a
Hi,

That example only demonstrates how to store a SINGLE dataset, which would
not be the same as an array.

--
Calvin Smith
http://www.CalvinSmithSoftware.com - Automation Code
http://www.SpanglesNY.com - Fendi, Prada, Von Dutch, etc - 60% off
"r0adh0g" <ro*****@nospam.phreaker.net> wrote in message
news:40********@news.binaries.net...
Instead of using an array consider creating your own variable type:
VBA (Access 95 onwards) allows you to return an entire structure of values. In database terms, this is analogous to returning an entire record rather
than a single field. For example, imagine an accounting database that needs to summarize income by the categories Wages, Dividends, and Other. VBA
allows you to declare a user-defined type to handle this structure:

Public Type Income
Wages As Currency
Dividends As Currency
Other As Currency
Total As Currency
End TypeYou can now use this structure as the return type for a
function. In a real situation, the function would look up your database
tables to get the values, but the return values would be assigned like this:
Function GetIncome() As Income
GetIncome.Wages = 950
GetIncome.Dividends = 570
GetIncome.Other = 52
GetIncome.Total = GetIncome.Wages + GetIncome.Dividends +
GetIncome.Other
End FunctionTo use the function, you could type into the Immediate
Window:

? GetIncome().Wagesor you could include a text box on a report and set
its ControlSource property to:

= GetIncome().Total(Note: the use of "Public" in the Type declaration
gives it sufficient scope.)

Programmers with a background in C will instantly recognize the
possibilities now that user-defined types can be returned from functions. If you're keen, user-defined types can even be based on other user-defined
types.
"Norman Fritag" <mt*****@ozemail.com.au> wrote in message
news:%w****************@nnrp1.ozemail.com.au...


Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.