If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > compare value in textbox with database?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-25-04, 05:13
azifa7980 azifa7980 is offline
Registered User
 
Join Date: Aug 2004
Posts: 15
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.
Reply With Quote
  #2 (permalink)  
Old 08-25-04, 06:53
SCIROCCO SCIROCCO is offline
Registered User
 
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!
Reply With Quote
  #3 (permalink)  
Old 08-26-04, 05:46
azifa7980 azifa7980 is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 08-26-04, 10:56
Marvels Marvels is offline
Registered User
 
Join Date: Jul 2003
Location: Amsterdam, Nederland
Posts: 449
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
Reply With Quote
  #5 (permalink)  
Old 09-01-04, 23:10
azifa7980 azifa7980 is offline
Registered User
 
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....
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On