A family of Microsoft relational database management systems designed for ease of use.
These both work for me:
These two examples work for me:
Public Function GetServerName() As String
With CurrentDb.QueryDefs("qryPassReturn")
.SQL = "select @@SERVERNAME as 'sname' "
GetServerName = .OpenRecordset()(0)
End With
End Function
Public Function GetServerName2() As String
Dim rst As DAO.Recordset
Dim ServerName As String
With CurrentDb.QueryDefs("qryPassReturn")
.SQL = "select @@SERVERNAME as 'sname' "
Set rst = .OpenRecordset
GetServerName2 = rst(0) ' or rst!sname
End With
End Function
In your sample, you execute the command but don’t grab or set any return values.
In my above examples, I also don’t set the connection string, but in fact saved the connection string when I saved the above pass-though.
Regards,
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada