CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Textbox

  1. #1
    Join Date
    Apr 2001
    Location
    Andhra Pradesh,INDIA
    Posts
    11

    Textbox

    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
    [email protected]


  2. #2
    Join Date
    Feb 2000
    Location
    Ireland
    Posts
    808

    Re: Textbox

    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




  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Textbox

    Don't forget to use .... = " & Val(Text1.text) in TH1 answer

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  4. #4
    Join Date
    Feb 2001
    Location
    PA
    Posts
    163

    Re: Textbox

    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







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