Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2004
    Posts
    15

    Unanswered: compare value in textbox with database?

    hi,
    i have a problem. I create 2 forms in vb. Form1 contain a textbox that get value of employee id.when the employee id is same with the data in the database(i use ADO data control), it will go to Form2. In Form2 contain 2 textboxes employee id and employee name, a command button for save the data into database. How is the coding to match the employee id in the textbox with database?And how to display back the employee id in other form(enabled it if possible). Please somebody help me!!i need it as soon as possible.
    thank you.

  2. #2
    Join Date
    Mar 2004
    Location
    www.scirocco.ca
    Posts
    346
    Could you please post the code that you are using to intilise the control. Depending on the CursorType and LockType the coding will be different.
    http://www.scirocco.ca/images/banner...occobanner.gif

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

  3. #3
    Join Date
    Aug 2004
    Posts
    15

    compare value in textbox with database?

    hi,
    i try to create this coding(i not try yet this coding). i want you to see the coding first and if there any mistake, can you correct it for me?

    Private Sub txtOprID_Change()
    Dim intMsg As MsgBox
    If txtOprID=.DataField("oprid") then
    Form2.Show
    Form1.Hide
    Else
    intMsg="You are not allowed to access the form"
    End If
    End Sub

    I hope that you can help me..i need it URGENT!
    thank you.

  4. #4
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Post Hi

    Add a button on the first Form
    dont use the txt_change in that way, it will be triggerd every time the user enters a letter. SO if he wants to write "azifa" the change will be triggerd with evry letter he/she typs and will get an Msgbox, verry anoying

    OK in the button_click
    you set the code

    Private Sub button1_click()
    dim sql as string

    me.DataField.recordsource = "Select * from TABLENAME " & _
    " WHERE oprid LIKE " & me.txtOprID.text
    ' PS. if oprid is a number (1256)wich i hope it issn't use = instead of LIKE
    ' if oprid is in textvalue so "Hello" better to use LIKE instead of =

    me.DataField.refresh
    if me.DataField.recordset.recorcount <=0 then
    msgbox "Sorry there seems to be an error", vbokonly+vbcritical,"No current record"
    exit sub
    else
    If me.txtOprID.text=me.DataField.recordset("oprid") then
    Form1.Hide
    Form2.Show
    Else
    Msgbox "You are not allowed to access the form", vbokonly+vbcritical,"Access Denid"
    End If
    End If
    End Sub

    in the form load of frm2
    you set

    Privat Form2_load
    with me
    .txtOprID.text = Form1.DataField.recordset("oprid")
    .txtID.text = Form1.DataField.recordset("ID")
    .txtOprID.enabled = false
    .txtID.enabled = false
    end with

    end sub

  5. #5
    Join Date
    Aug 2004
    Posts
    15

    compare the ID in the textbox with database?

    hi,
    i've tried the coding you gave to me but i got an error:

    Compile error:
    method or data member not found.

    Private Sub button1_click()
    dim sql as string

    me.oprid( i got the error here!).recordsource = "Select * from master_pcba_debug WHERE oprid LIKE " & me.txtOprID.text
    ' PS. if oprid is a number (1256)wich i hope it issn't use = instead of LIKE
    ' if oprid is in textvalue so "Hello" better to use LIKE instead of =

    me.oprid.refresh
    if me.oprid.recordset.recorcount <=0 then
    msgbox "Sorry there seems to be an error", vbokonly+vbcritical,"No current record"
    exit sub
    else
    If me.txtOprID.text=me.oprid.recordset("oprid") then
    Form1.Hide
    Form2.Show
    Else
    Msgbox "You are not allowed to access the form", vbokonly+vbcritical,"Access Denid"
    End If
    End If
    End Sub

    can you tell me why i get the error? please help me....

Posting Permissions

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