Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

visual basic functions

Posted on 2004-10-12
6
Medium Priority
?
197 Views
Last Modified: 2010-04-17
hi there, I've created a function that should return  results on a datalist object:(here are the codes):
======
Public Function myactive_users(current_list As datalist)
   
    Adodc1.ConnectionString = "DSN=mydsn"
    Adodc1.RecordSource = "select distinct myUsers from myTable  order by Myuser"
    Adodc1.Refresh
   
    current_list.DataField = "myUsers"
    current_list.ListField = "myUsers"
   
    Set current_list.DataSource = Adodc1
    Set current_list.RowSource = Adodc1
   
End Function
=========
Now, when I call this function to populate results on another datalist, the compiler tells me  "error mismach". This is what I am doing: myactive_users(this_datalist1)
Anybody can help on how to do that properly?
I will apreciate ur help.
F.

0
Comment
Question by:Francisco_M
4 Comments
 
LVL 12

Expert Comment

by:farsight
ID: 12292714
I don't fully understand your issue.  But this might get you started ...

[VB.NET]
Public Function myactive_users(current_list As datalist) As ???_What_Type_???

   Return ???_What_Object_Of_The_Given_Type_???    
End Function

In VB6, you'd use:
  myactive_users = ???_What_Object_Of_The_Given_Type_???
instead of the Return statement.
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 240 total points
ID: 12293274
On which line do you get the error?

Remove parenthesis or add a CALL statement like this:
myactive_users this_datalist1
call myactive_users(this_datalist1)

Also add the Recordset to these 2 lines:
    Set current_list.DataSource = Adodc1.Recordset
    Set current_list.RowSource = Adodc1.Recordset
0
 

Expert Comment

by:huyntminh
ID: 12294337
I agree with emoreau, and remember, your datalist object "this_datalist1" must be initialized before passing it to the function myactive_users.
Hope u sucess.
0
 

Author Comment

by:Francisco_M
ID: 13542752
THANKS emoreau,
It worked!
Sorry to reply so late!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Six Sigma Control Plans
Loops Section Overview

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question