Results 1 to 4 of 4
  1. #1
    Join Date
    May 2009
    Posts
    2

    Unanswered: access module function to SQL function

    I'm the first time to convert access module to SQL function, any one can help me ? thanks

    Function Access(ByVal D As String) As Boolean
    Dim Db As Database
    Dim RS As Recordset
    Dim Criteria As String

    If Not IsNull(D) And Len(D) > 0 And Not IsNull(Currlogin) Then
    Set Db = CurrentDb
    Criteria = "Select * from SysDept where Imuser = '" & Currlogin & "' and Dept = '" & D & "' "
    Set RS = Db.OpenRecordset(Criteria, dbOpenDynaset, dbReadOnly)
    If RS.RecordCount > 0 Then
    RS.MoveLast
    RS.MoveFirst
    Access = True
    Else
    Access = False
    End If
    Set RS = Nothing
    Set Db = Nothing
    Else
    Access = False
    End If
    End Function

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Please explain in English (rather than posting code) what you want this "SQL function" to do (part of why I ask is because there is no such thing in Access).
    I can see what the VBA does, but I don't know what you want the SQL to do. When you say "SQL function", you don't mean "SQL Server function", right?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    May 2009
    Posts
    2
    Yes, this function is a part of a module in the access. i have to migrate the access to SQL Server. lots of similar function like this in the access. could you please help to convert to SQL server function? thanks

    Create Function Access ()
    return table.....

    I've no idea
    Last edited by kn1394; 05-06-09 at 22:35.

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Ok. I will move this to the SQL Server forum.

    Note - SQL is a language, SQL Server is a database product.

    Code:
    IF EXISTS(SELECT NULL FROM SysDept WHERE Imuser = @Currlogin  and Dept = @d)
    RETURN 1
    ELSE
    RETURN 0
    END
    This is broadly the code for the clever bit. The rest is standard scalar function SQL. Look up User Defined Functions in Books Online and post what you come up with.
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

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