title: Object variable error in vba
body: <p>Trying to create a username/password validation form. getting the the following error "Object variable or with block variable not set" when i click login button i.e comamand1_click(). when i click debug it points to </p>
  
  <pre><code>&gt; rs.ActiveConnection = conn
  </code></pre>
  
  <p>The code that i typed:</p>
  
  <pre><code>Dim a
  Dim conn As ADODB.Connection
  Dim rs As ADODB.Recordset
  
  Private Sub Command1_Click()
  Set conn = New ADODB.Connection
  conn.ConnectionString = "Provider = Microsoft.ACE.OLEDB.12.0; Data Source = C:\VB Project\logindetails1.mdb"
  conn.Open
  
  If conn = Null Then
      MsgBox ("no db")
      End
  End If
  
  rs.ActiveConnection = conn
  rs.Source = "select * from login"
  rs.Open
  
  rs.MoveFirst
  While Not rs.EOF
  If Text1.Text = rs.Fields("id") And Text2.Text = rs.Fields("password") Then
      a = 1
  Else
      a = 0
  End If
  Wend
  rs.Close
  conn.Close
  Set rs = Nothing
  Set conn = Nothing
  
  If a = 1 Then
      MsgBox ("Login Successful!!")
  Else
      MsgBox ("Invalid Details!!")
  End If
  End Sub
  
  Private Sub Command2_Click()
  Text1.Text = ""
  Text2.Text = ""
  End Sub
  
  Private Sub Command3_Click()
  End
  End Sub
  </code></pre>