Access 2013- Web App-User Info retrieval only works from ON-START macro (1 Viewer)

tacklers

New member
Local time
Today, 17:31
Joined
Jun 11, 2014
Messages
6
With my 'Inside-Out Access 2013' Bible I have built a cool web app in 365.

There is only a one-time possibility to grab the user info. Is this right?

The Action catalog shown with 'On-Start' macros includes 'User Interface Commands' which will retrieve the logged on user via UserDisplayName(0).

The same is not available for On-Event, Data or other macros.

If this is right is there another way to persist a SetLocalVariable content across the user session. I just want to set the user name when a record is updated on an on-event macro without having to manually code a user table and an app login routine.

Cheers, Richard
 

AccessJunkie

Senior Managing Editor
Local time
Today, 09:31
Joined
May 11, 2006
Messages
278
Hi Richard,

There is a distinct difference between macro actions available at the UI layer and at the data layer. The reason for this is that actions performed in the data macro context need to be able to execute without any knowledge of the UI layer. Let me give you an example.

Data macros in Access 2013 web apps are translated into SQL Triggers and Stored Procedures. If you opened up SQL Server Management Studio and added/edited/deleted a record through this entry point, those actions won't have any knowledge of a view control reference or a variable you defined in a view event. So all the actions we allow in data macros must be able to run independently of the view/form context.

The only way to pass down to the data layer variables from the UI layer in Access 2013 web apps is to create a named data macro that can take parameters. You can pass those values down that way.

For your scenario, I would define a Short Text field in your table to hold the user name creating the record. On your view, drop a text box onto the view bound to that field. I would then make the control Enabled = No so users cannot manipulate the value. You can then define the Default Value property of the control to the current user of the app.

If you define a variable using the Set Variable macro action, it will persist until the user closes their browser tab, refreshes their browser window, or your macro logic changes the value to something else.

Hope that helps,

--------------------
Jeff Conrad - Access Junkie - MVP Alumnus
Senior SDET - Access Test Team - Microsoft Corporation

Author - Microsoft Access 2013 Inside Out
Author - Microsoft Access 2010 Inside Out
Co-author - Microsoft Office Access 2007 Inside Out
Access 2007/2010/2013 Info: http://www.AccessJunkie.com

----------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.mspx
----------
 

Users who are viewing this thread

Top Bottom