I have a passthrough query in an Access 2010 application, which I\'m using to call a stored procedure on a SQL Server backend. The stored procedure takes a parameter that I need
You can use this code:
With CurrentDb.QueryDefs("MyPass")
.SQL = "exec spMyProc '" & getUserName() & "'"
.Execute
End With
Because getUserName() is a local VBA function, then you need to pre-evaluate the actual string sent to SQL server. As above shows using a saved pass-though is "handy" since you don't have to deal with connection strings etc.