You could simply Google ms access execute (or similar) but I'm feeling generous today
Will also show you how code tags (forum toolbar #) and indentation code easier to read, and provide example of error handler, which almost all procedures should have. You can also take some shortcuts such as
Me.txtInitials = GetInitials(Me.txtUser) since you don't use the variable more than once (that I noticed) and that was just to set the form control value anyway.
Code:
Private Sub Form_Load()
'---Set access levels by role for menu items.---
Dim sPermit As String, sInitials As String
Dim iAccess As Integer
Dim ctl As Access.control
Dim db As DAO.Database
On Error GoTo errHandler
Set db = CurrentDb
Me.txtUser = Environ("username")
'If IsNothing(Me.txtUser) Then IsNothing is for Objects. This would likely never true as long as the control exists on the form
If Me.txtUser & vbNullString = "" Then 'one way of determining no value is there
sPermit = "ReadOnly"
DoCmd.OpenForm "Staff", acNormal, , , acFormAdd, acDialog
Else
sPermit = GetPermission(Me.txtUser)
sInitials = GetInitials(Me.txtUser)
End If
Select Case sPermit
Case "Admin"
iAccess = 5
Case "Lead"
iAccess = 4
Case "QA"
iAccess = 3
Case "User"
iAccess = 2
Case Else
iAccess = 1
End Select
Me.txtLevel = iAccess
Me.txtInitials = sInitials
'---Refresh Pending Sort Report subform---
DoCmd.Requery "qryPendingSrtRprtbyUser subform"
'---Delete records more than 60 days old---
'DoCmd.OpenQuery "qry60_day_delete"
db.Execute "qry60_day_delete", dbFailOnError
'DoCmd.OpenQuery "qry60_day_SrtRprt_delete"
db.Execute "qry60_day_SrtRprt_delete", dbFailOnError
'---determine splash screen to open---
'If iAccess = 1 Then
'DoCmd.OpenForm "frmUnauthSplash"
'Else
'DoCmd.OpenForm "frmSplash"
'End If
exitHere:
Set db = Nothing
Exit Sub
errHandler:
Msgbox "Error " & err.number & ": " & err.Description
Resume exitHere
End Sub