Advertisement
nandordudas

Form load: object error

Jun 29th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private pHash As daily_status_v1.clsHash
  5.  
  6. Private Sub Form_Load()
  7.  
  8. '   Error: 91 - Object variable or With block variable not set
  9.    Set pHash = New daily_status_v1.clsHash
  10.  
  11.     With Me
  12.         .NavigationButtons = False
  13.         .ScrollBars = 0
  14.         .Moveable = True
  15.         .ControlBox = False
  16.         .RecordSelectors = False
  17.         .RecordSource = "tblUser"
  18.  
  19.         With .cboUserName
  20.  
  21.             .RowSource = "" _
  22.                 & "SELECT " _
  23.                     & "u.Id, " _
  24.                     & "u.FirstName & ' ' & u.LastName " _
  25.                 & "FROM " _
  26.                     & "tblUser u " _
  27.                 & "ORDER BY " _
  28.                     & "u.FirstName & ' ' & u.LastName ASC"
  29.             .ColumnCount = 2
  30.             .ColumnWidths = "0;2"
  31.  
  32.         End With
  33.     End With
  34.  
  35. End Sub
  36.  
  37. Private Sub btnLogin_Click()
  38.  
  39.     Dim UiPassword As String
  40.  
  41.     UiPassword = Me.txtPassword.Value
  42.  
  43.     If Not VBA.Information.IsNull(UiPassword) Then
  44.  
  45.         Dim DbPassword As String, _
  46.             Criteria As String
  47.  
  48.         Criteria = "Id = " & Me.cboUserName.Value
  49.  
  50.         DbPassword = Application.DLookup("[Password]", "tblUser", Criteria)
  51.  
  52.         If pHash.Check(UiPassword, DbPassword) Then
  53.  
  54.             Application.DoCmd.Close acForm, Me.Name, acSaveYes
  55.  
  56.             Set pHash = Nothing
  57.  
  58.         End If
  59.     End If
  60.  
  61. End Sub
  62.  
  63. Private Sub cboUserName_NotInList(NewData As String, Response As Integer)
  64.  
  65.     Response = acDataErrContinue
  66.  
  67. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement