Hi Paula,
Try to invoke the VBA function directly within your Data Macro like so:
Value = MyEnviron("UserName")
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a data macro for an audit table which works great except for tracking the system user. In VBA I can use Eviron("UserName") but I need to do this via macro. Here is the macro:
If Updated("[Oasis_Barcode]") Then
Create a Record in Audit
Set Field
Name Audit.TableName
Value = “[Files]”
Set Field
Name Audit.RecordID
Value = [Files].[ID]
Set Field
Name Audit.ChangeBy
Value = ??? Cannot use Environ
Set Field
Name Audit.FieldName
Value = “[Oasis_Barcode]”
Set Field
Name Audit.OldValue
Value = [Old].[Oasis_Barcode]
Set Field
Name Audit.NewValue
Value = [Files].[Oasis_Barcode]
Set Field
Name Audit.ChangeDate
Value = Now()
End If
i have created a public function as a module:
Public Function MyEnviron(username As String) As String
MyEnviron = VBA.Environ(username)
End Function
but I am not that familiar with using functions and dont know how to call this into a macro - can anyone give me any pointers?
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Hi Paula,
Try to invoke the VBA function directly within your Data Macro like so:
Value = MyEnviron("UserName")
Thanks so much