2 Replies - 1318 Views - Last Post: 22 September 2013 - 06:49 AM Rate Topic: -----

#1 brerallia   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 164
  • Joined: 21-January 13

What to add in reference for module?

Posted 21 September 2013 - 09:26 PM

so i have this login form with this code

Dim llogin As New ADODB.Recordset

Private Sub Command1_Click()
If llogin.State = adStateOpen Then
End If

where u.Username='" & txt_username.Text & "'", c
llogin.Open "select * from Users where UserName ='" & txt_usernmae & "'", c
If llogin.RecordCount > 0 Then
    If llogin("Password") = txt_password Then
        c_user = llogin("FirstName")
        MsgBox "You have successfully logged in"
        MsgBox "Incorrect Password"
    End If
    MsgBox "User does not exist"
End If

End Sub

Private Sub Form_Load()
llogin.CursorLocation = adUseClient
llogin.CursorType = adOpenStatic
llogin.LockType = adLockOptimistic

txt_username = ""
txt_password = ""
End Sub

and a module to connect to database

Dim c As New ADODB.Connection
Dim current_user As String
Dim match As Boolean

Public Sub Connect()
c.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\StockInformationInquirySystem.mdb"
End Sub

Public Sub Disconnect()
Set c = Nothing
End Sub

i got this error everytime i click the login button

and it pointed the llogin.open ... line as the error to debug....
i tried to find out how to debug it and it seems that the module is the culprit...

I tried to remove the current module and replace it with another one that the code is the same.... very the same.. and when i run it and click the login button it doesnt get an error.... but when i shift the other module.... it runs an error...

is there any reference i forgot??? the code is the same..


Is This A Good Question/Topic? 0
  • +

Replies To: What to add in reference for module?

#2 jimzcoder   User is offline

  • D.I.C Regular

Reputation: 57
  • View blog
  • Posts: 351
  • Joined: 14-November 12

Re: What to add in reference for module?

Posted 22 September 2013 - 05:38 AM

honestly. i don't really get what your line #8 code is for.
have you tried removing that line and see what happens then?
Was This Post Helpful? 1
  • +
  • -

#3 andrewsw   User is offline

  • blow up my boots
  • member icon

Reputation: 6551
  • View blog
  • Posts: 26,559
  • Joined: 12-December 12

Re: What to add in reference for module?

Posted 22 September 2013 - 06:49 AM

You have misspelt txt_usernmae. Adding Option Explicit to the top of every module will help you track down these errors.

This will also tell you if the variable c is in scope - available in the Click event.

This post has been edited by andrewsw: 22 September 2013 - 06:55 AM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1