Solved

visual basic functions

Posted on 2004-10-12
6
190 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
6 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 69

Accepted Solution

by:
Éric Moreau earned 60 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
This article will show, step by step, how to integrate R code into a R Sweave document
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

919 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now