Consulting

Results 1 to 8 of 8

Thread: Functions

  1. #1
    VBAX Mentor
    Joined
    Oct 2007
    Posts
    357
    Location

    Question Functions

    Hi All,

    I create afunction which takes on parameter & provides one output.

    But now I need the same function to provide a two outputs but will take only one parameter/input.

    How to go about doing it.

    Please guide.



    Regards
    Sudhir

  2. #2
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    We need more detail. What exactly are you trying to accomplish, and what is the code for the existing function?
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  3. #3
    VBAX Mentor
    Joined
    Oct 2007
    Posts
    357
    Location
    I am giving 4 char code as input to the function.

    The function in turn is running a query to my database & as per the code returning me the required data.

    [VBA]
    Sub Test()

    dim Parnam as string

    VCde = 1254

    Parnam = ListName (VCde)

    Msgbox Parnam

    End Sub

    Function ListName(Vencode As String) As String
    Dim cn As ADODB.Connection, rs, rs2, rs3 As ADODB.Recordset
    Dim CS As String
    Set cn = New ADODB.Connection
    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
    "Data Source=D:\Project\Data.mdb;"
    'open a recordset
    Set rs = New ADODB.Recordset
    Set rs2 = New ADODB.Recordset
    'rs.Close
    rs.Open "SELECT List.[Handler], List.[Type] FROM List WHERE (((List.VC)='" & Vencode & "')) ;", cn, adOpenStatic, adLockOptimistic

    If rs.RecordCount > 0 Then
    ListName = rs("Handler").Value
    rs.Close
    End If


    End Function

    [/VBA]

    I want to provide the Type also in the output.

    Regards
    Sudhir

  4. #4
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    I want to provide the Type also in the output.
    The Type of what? Are you referring to the data type of the returned value, or something within your table?
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  5. #5
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]ListName = rs("Handler").Value & ":" & [type]
    [/VBA]
    Not sure about the Syntax, but you can Split the output in the original sub.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6
    VBAX Mentor
    Joined
    Oct 2007
    Posts
    357
    Location
    Its rs("type").value

  7. #7
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    So does that suffice?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  8. #8
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    Or you could try:
    [VBA]ListName = rs("Handler").Value & rs("Type").Value[/VBA]
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •