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

Passing arrays to functions

P: n/a
Hi,
I'm having trouble passing an array to a function,
like this:

Dim sFieldsNotRequired(11), sFieldsWithSpecificValues(5) As String
Dim sCaseErrMsgs As String
Dim vFieldsSpecificValues(5) As Variant
sFieldsNotRequired(0) = "middleName"
etc...

sFieldsWithSpecificValues(0) = "InfoRecd"
etc...

vFieldsSpecificValues(0) = True
etc...
Dim sCaseSQL As String
sRecSQL = "SELECT * from table WHERE ID = " & iID

Dim bInfoValidates As Boolean

bInfoValidates = CheckRecordset(sSQL, sFieldsNotRequired(),_
sFieldsWithSpecificValues(), _
vFieldsSpecificValues(), sCaseErrMsgs)
Where
CheckRecordset is defined as:

Function CheckRecordset(sRecordsetSQL As String, sFieldsNotRequired() As
String, _
sFieldsWithSpecificValues() As String, _
vFieldsSpecificValues() As Variant,
sErrMessages As String) As Boolean

The trouble is I get the error:

type mismatch array or user-defined type expected

This is also true when I call the function as

bInfoValidates = CheckRecordset(sSQL, sFieldsNotRequired,_
sFieldsWithSpecificValues, _
vFieldsSpecificValues, sCaseErrMsgs)

can somebody give me some clues as to what's going on?

Thanks,

Eric
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Eric Ellsworth wrote:
Hi,
I'm having trouble passing an array to a function,
like this:

Dim sFieldsNotRequired(11), sFieldsWithSpecificValues(5) As String
Dim sCaseErrMsgs As String
Dim vFieldsSpecificValues(5) As Variant < SNIP > Function CheckRecordset(sRecordsetSQL As String, sFieldsNotRequired() As
String, _
sFieldsWithSpecificValues() As String, _
vFieldsSpecificValues() As Variant, sErrMessages
As String) As Boolean

The trouble is I get the error:
type mismatch array or user-defined type expected
This is also true when I call the function as

< SNIP >

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This Dim:

Dim sFieldsNotRequired(11), sFieldsWithSpecificValues(5) As String

Sets the array sFieldsNotRequired() to a Variant array, not a String
array. This is correct declaration:

Dim sFieldsNotRequired(11) As String, sFieldsWithSpecificValues(5) As
String

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQHdTPIechKqOuFEgEQLmNQCg+yAyMvtiaBdRK3P7Chs4M/FKj5UAoMCp
9Xp0mvfAFz52iGp8o/+yztiB
=ps64
-----END PGP SIGNATURE-----

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.