Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Access VBA code for generic username??

Status
Not open for further replies.

coder30

Programmer
Apr 7, 2006
16
US
In my Docmd.TransferSpreadsheet line, I need the syntax or wildcard that will allow me to send this to any user's desktop. I was told %username%, but that does not work. Does anyone have any ideas?



'------------------------------------------------------------
' PS_Contract_Perf_by_Qtr
'
'------------------------------------------------------------
Function PS_Contract_Perf_by_Qtr()
On Error GoTo PS_Contract_Perf_by_Qtr_Err

DoCmd.SetWarnings False
' Transfer Data to Template
DoCmd.TransferSpreadsheet acExport, 8, "Contract Purchases by Quarters", "C:\Documents and Settings\%username%\Desktop\QuikReports\PSContractPerformanceByQtr.xls", True, "Data"
' Open PS Contract Performance By Qtr
DoCmd.RunMacro "Open Contract Perf by Qtr", , ""


PS_Contract_Perf_by_Qtr_Exit:
Exit Function

PS_Contract_Perf_by_Qtr_Err:
MsgBox Error$
Resume PS_Contract_Perf_by_Qtr_Exit

End Function
 
Replace this:
%username%
with this:
" & Environ("username") & "

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top