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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2007 Workaround for Environ() 1

Status
Not open for further replies.

ToyFox

Programmer
Jan 24, 2009
161
US
I inherited a database that uses Environ() function for the default value in the table definition. This worked fine in 2003 but is not supported in 2007. I know there is a Dev Ashish function but can that function work in the table defintion.
 
Try putting it on a screen that calls the query and reference Forms!myform!UserID. That works for me when I need to use a variable in a query it can't get too. Also I have a module to pass data called get_global in some queries I filter by populating a global variable then add get_global (userid) the function returns the date. This one function can be used to pass any variable to a query.

Public Function get_global(G_name As String) As Variant

Select Case G_name
Case "UserId"
get_global = Environ("username")
Case "Start_Date"
get_global = gblReportDate
Case "End_Date"
get_global = gblReportDate2
End Select

End Function
 
I wasn't aware that Environ() would work in a table definition field default.

You could/should do all of your data editing through forms where you could use Dev's function as the default.

Duane
Hook'D on Access
MS Access MVP
 
Thanks for your response. I did my data editing using Dev's function in the forms and it worked fine.
But, it is true in 2003, the ENVIRON() function works in a table def default value field. We had Environ("UserName").
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top