Click to See Complete Forum and Search --> : Textbox
chakri_m16
May 9th, 2001, 11:27 PM
suppose i enter in a textbox 260420 and then save it to the database.again when the user enters the same nuber it should display an error message that the number alredy exists.this is not auto generated no.how can i check for 6 digit number or more.please help me.
thank u
chakri_t@rediffmail.com
TH1
May 10th, 2001, 03:10 AM
Just do a select statement on the database to check if the number exists before you try inserting it.
sql="select count(*) as AlreadyExists from table where number=" & text1.text
if your recordset is called rs then if rs!AlreadyExists>0 then show them the message and don't try to insert the number
Hope this helps
Iouri
May 10th, 2001, 07:09 AM
Don't forget to use .... = " & Val(Text1.text) in TH1 answer
Iouri Boutchkine
iouri@hotsheet.com
Cubbie
May 10th, 2001, 07:20 AM
Another way would be to open a recordset and test to see if the recordset is empty or not...
mysql = "Select Doc_Number from Table where Doc_Number = '" & txtData.Text & "'"
'*************************************************
'Code to Open a recordset here(static cursor or snapshot)
'**********************************************
' Test to see if recordset is empty or not
If not(rs.bof and rs.eof) then
MsgBox "Document number '" & txtData.Text & "' already exists." & vbNewLine & "Please enter another document number", vbExclamation, "Document Number Validation"
End If
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.