' ============================================================
' Copyright (c) 2025-2026 Peter Bryant (Corylus Business Systems)
' and Andrew Richards (The IT Service Ltd)
' Part of VBAuth - https:
' Licensed under the MIT Licence - see LICENCE.txt
' This copyright notice must not be removed or altered.
' ============================================================
' ============================================================
' Form code example for the Who Am I feature.
' This procedure belongs in your Access form's code-behind.
'
' It cannot be imported directly as a module — copy the
' procedure into your form module manually.
'
' PORTING NOTE:
' WhoAmI is a setup verification and demonstration function.
' In the VBAuth demo database it is called from the Setup
' Wizard to confirm that authentication is working correctly.
' It is not intended as a production data-retrieval feature,
' but the call pattern it demonstrates is identical to any
' other VBAuth GET request and can be adapted freely.
'
' FORM CONTROLS REQUIRED:
' txtWhoAmI Text box — displays the returned profile
' cmdWhoAmI Command button — triggers the call
'
' DEPENDENCIES:
' modCurrentUser.bas (WhoAmI)
' modVBAuthGlobalConstants.bas
' JSONConverter.bas (Tim Hall VBA-JSON)
'
' PREREQUISITE:
' lclVBAuthAdmin must contain a correctly configured record
' for this feature. See README_WhoAmI.md for required values.
' ============================================================
Option Compare Database
Option Explicit
' ============================================================
' cmdWhoAmI_Click
' Calls WhoAmI to retrieve the authenticated user's profile
' from the Graph /me endpoint and displays the result.
' ============================================================
Private Sub cmdWhoAmI_Click()
Dim strResult As String
Me.txtWhoAmI = "Retrieving user details..."
Me.Repaint
If WhoAmI(strResult) Then
Me.txtWhoAmI = strResult
Else
Me.txtWhoAmI = ""
MsgBox "Could not retrieve user details." & vbCrLf & vbCrLf & strMessage, _
vbCritical, "Who Am I"
End If
End SubCode language: PHP (php)