CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2011
    Posts
    5

    [RESOLVED] [HELP] Kindly help...

    Please help me on my project. I used this for my log in form. The registration form worked well and its easy for me. There are many errors almost 3. The errors are on the first 3 statements.

    line 1: syntax error (missing operator) in query expression 'ID Number = '[what i type]''.
    line 2: method 'refresh' of object 'iadodc' failed
    line 3: object variable or with block variable not set


    Code:
    Private Sub Command1_Click()
    
    Adodc1.RecordSource = ("select * from Student where ID Number ='" & Text1.Text & "'") '<=== line 1
    Adodc1.Refresh    '<=== line 2
    If (Adodc1.Recordset.EOF = False) Then    '<=== line 3
        If Adodc1.Recordset.Fields("Password") = Text2.Text Then
        MsgBox ("Successfully Logged-in"), vbInformation, "Log-in"
        Homepage.Label1.Caption = Text1.Text
        Homepage.Label2.Visible = True
        Login.Visible = False
        Homepage.Visible = True
        Else
        Val (X) + 1
        MsgBox ("Wrong Log-in information"), vbInformation + vbRetryCancel, "Log-in"
        End If
    Else
        Val (X) + 1
        MsgBox ("Wrong Log-in information"), vbInformation + vbRetryCancel, "Log-in"
    End If
    
    If X = 3 Then
    MsgBox ("Maximum Log-in Reached!"), vbCritical + vbOKOnly, "Log-in"
    End If
    End Sub
    
    Private Sub Command2_Click()
    answer = MsgBox("Do you want to cancel?", vbExclamation + vbYesNo, "Confirm")
    If answer = vbYes Then
    End
    Else
    MsgBox "Action canceled", vbInformation, "Confirm"
    End If
    End Sub
    
    Private Sub Form_Load()
    Dim X As Integer
    X = 0
    End Sub

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: [HELP] Kindly help...

    If the ID Number is a numeric field as the name implies then you would not use the single quote characters. Using these for numeric fields will cause an error.

    other errors are likely caused by the fact that your query did not work.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jan 2011
    Posts
    5

    Re: [HELP] Kindly help...

    Quote Originally Posted by DataMiser View Post
    If the ID Number is a numeric field as the name implies then you would not use the single quote characters. Using these for numeric fields will cause an error.

    other errors are likely caused by the fact that your query did not work.
    the id number has "-" on it so i thinks it's not considered to have val() on it. i think my code is correct but it wont run without error o_O... why?...

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: [HELP] Kindly help...

    I just noticed you have a space in your field name as well. you must use [ ] around field names which contain space or use reserved words.

    Code:
    "select * from Student where [ID Number] =  "
    And again if the datatype of the field is numeric which is implied by the field name then you do not use quotes around the value in your query. If it is a text field then you must use the quotes,
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Jan 2011
    Posts
    5

    Re: [HELP] Kindly help...

    Quote Originally Posted by DataMiser View Post
    I just noticed you have a space in your field name as well. you must use [ ] around field names which contain space or use reserved words.

    Code:
    "select * from Student where [ID Number] =  "
    And again if the datatype of the field is numeric which is implied by the field name then you do not use quotes around the value in your query. If it is a text field then you must use the quotes,
    MY GOD! Thank You! It worked...

  6. #6
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: [RESOLVED] [HELP] Kindly help...

    Glad I could help
    Always use [code][/code] tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured