sportsguy
Finance wiz, Access hack
- Local time
- Today, 10:07
- Joined
- Dec 28, 2004
- Messages
- 363
I am not sure which required field is missing, can anyone make an observation which I cannot seem to see. The point of the code is to verify the computer logon name against a predetermined list of logon names before continuing. The approved logon names are in a table, which is selected in a drop down box by sales district number, there will be only one record returned.
thanks in advance
thanks in advance
Code:
Private Sub Continue_Click()
Dim strUserName As String
Dim anyLogon As String
Dim Validated As Boolean
On Error GoTo Err_Continue
strUserName = ap_GetUserName()
Dim cnnLocal As New ADODB.Connection
Set cnnLocal = CurrentProject.Connection
Dim rstCurr As New ADODB.Recordset
rstCurr.Open "SELECT tblDISTRICTS.logon FROM tblDISTRICTS WHERE (((tblDISTRICTS.strDistrict)=Forms!setup.cboxDistrict));", cnnLocal, adOpenForwardOnly, adLockReadOnly, adCmdText
anyLogon = rstCurr.GetString(, , , , "Null")
Debug.Print "Logon name = " & anyLogon
If anyLogon = strUserName Then
Validated = True
Else
Validated = False
End If
rstCurr.Close
cnnLocal.Close
Set cnnLocal = Nothing
Set rstCurr = Nothing
' Validation Sequence
If Validated = True Or strUserName = "adminuser" Then
GoTo OKtoLoad
Else
MsgBox "Please Contact your NSSM to Continue", vbCritical, "VALIDATION ERROR!"
End If
GoTo Exit_Continue
OKtoLoad:
Debug.Print "OktoLoad"
Exit_Continue:
Exit sub
Err_Continue:
error coding
End Sub