Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2002
    Posts
    7

    Talking Unanswered: Username from MS Access

    I converted a query from MSAccess to SQL Server into a stored procedure but having a hard time looking for a way to get the value of CurrentUser() function from MSAccess and pass it into the stored procedure. I tried passing the CurrentUser() as a parameter to my stored procedure by calling it from a query in MSAccess, but since my Access query is a pass-through query it can't understand the CurrentUser() function I'm trying to pass.

    HELP!!!

  2. #2
    Join Date
    Dec 2001
    Location
    Toronto, Canada
    Posts
    335
    Couldn't you use the SQL property of the QUERYDEF object to change the sql command.
    Code:
    myQDF.SQL = "exec my_proc " & CurrentUser()
    After setting the command you can then execute it.
    MCDBA

  3. #3
    Join Date
    Apr 2002
    Posts
    7
    Thanks achorozy, I already got it the other day and it's pretty the same to what you have suggested. I guess that's why you're already a guru because it took me 3 days to figure this one out.

    Here's the code...

    Private Function AnnuityImport_23_PubHeaderAdd_PT() 'JLS
    On Error GoTo Errors
    Dim strsql As String
    Dim qdef As QueryDef

    strsql = "exec procAnnuityImport_23_PubHeaderAdd @strUserID='" & CurrentUser() & "'"
    Set qdef = CurrentDb.QueryDefs("qryAnnuityImport_23_PubHeader Add_PT")
    qdef.SQL = strsql
    qdef.Execute
    qdef.Close
    Exit Function
    Errors:
    If Err.Number <> 3146 Then
    MsgBox Err.Number & " " & Err.Description, vbCritical, "Error encountered in function AnnuityImport_23_PubHeaderAdd_PT."
    End If
    Resume Next
    End Function

Posting Permissions

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