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 / Modules / DAO / VBA / February 2005

Tip: Looking for answers? Try searching our database.

Passing Array & value to function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gord D - 22 Feb 2005 14:50 GMT
Hi I have an array, created by a recordset, and I want to pass it to a
function along with the value.  the function will check if the value is in
the array and return YES / NO
I'm getting a comile error of TypeMismatch: Array
I have a feeling the array that is created by the Getrecords is my problem
as I don't now what type it is.

Private Sub main()
   
   Dim rs As New ADODB.Recordset
   rs.CursorLocation = adUseClient
   rs.Open "select ID from tAccounts", CurrentProject.Connection,
adOpenDynamic, adLockOptimistic
   iPos = rs.RecordCount
   rs.MoveFirst
   aIFIS = rs.GetRows(iPos)
   rs.Close
   
   testval = "123456"
   retval =  ValidAccount aIFIS, testval
 msgbox retval
End Sub

Private Function ValidAccount(aIFISx() As String, sValx As String)
       Dim sValx As String, i As Integer
       MsgBox aIFISx(i)
       For i = LBound(aIFISx) To UBound(aIFISx)
           If sValx = aIFISx(i) Then
               sValx = "VALID"
               Exit For
           Else
               sValx= "NOTVALID"
           End If
       Next i
End Function
Alex Dybenko - 22 Feb 2005 15:18 GMT
Try to declare aIFIS  as variant, and pass it as variant to ValidAccount
instead of string
BTW, correct syntax is:
retval =  ValidAccount (aIFIS, testval)

Signature

Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com

> Hi I have an array, created by a recordset, and I want to pass it to a
> function along with the value.  the function will check if the value is in
[quoted text clipped - 31 lines]
>        Next i
> End Function
Andi Mayer.. - 22 Feb 2005 15:26 GMT
>Hi I have an array, created by a recordset, and I want to pass it to a
>function along with the value.  the function will check if the value is in
[quoted text clipped - 31 lines]
>        Next i
>End Function

this array has the be a variant

Signature

If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message
MW

 
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.