Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Primary key error msg

Primary key error msg

Scheduled Pinned Locked Moved Visual Basic
helpquestionannouncement
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rrrriiizz
    wrote on last edited by
    #1

    hello all, am a begginer in vb. am creating one small project using vb6.0 and msacess 2003. my problem is i have set one field as a Primary key in that if the no entered is alredy there in databse it was return some error msg, but in my project instead of that error msg i want to create some msgbox that told the no u typed is already there pease choose another. please give me any syntax for that coding? below code is return by me in the insert click. Please give me suggesstion it is very urgent. Private Sub cmdverify_Click() If (Text1.Text = "") Then MsgBox ("Please Scan Properly") Else rs.Open "select * from barcode", con, adOpenDynamic, adLockOptimistic rs.AddNew rs!barcode = Text1.Text rs.Update Text1.Text = "" Text1.SetFocus rs.Close End If End Sub

    K 1 Reply Last reply
    0
    • R rrrriiizz

      hello all, am a begginer in vb. am creating one small project using vb6.0 and msacess 2003. my problem is i have set one field as a Primary key in that if the no entered is alredy there in databse it was return some error msg, but in my project instead of that error msg i want to create some msgbox that told the no u typed is already there pease choose another. please give me any syntax for that coding? below code is return by me in the insert click. Please give me suggesstion it is very urgent. Private Sub cmdverify_Click() If (Text1.Text = "") Then MsgBox ("Please Scan Properly") Else rs.Open "select * from barcode", con, adOpenDynamic, adLockOptimistic rs.AddNew rs!barcode = Text1.Text rs.Update Text1.Text = "" Text1.SetFocus rs.Close End If End Sub

      K Offline
      K Offline
      klaydze
      wrote on last edited by
      #2

      try this: rs.Open "Select * from barcode Where barcodeid='" & txtbarcodeid.Text & "',con,1,3 if rs.eof then rs.addnew rs.fields("barcode")=text1.text rs.Update else // if existed msgbox "Record Existed" endif NOTE: make sure you have a "WHERE" to your SELECT so that you have a unique record to search.

      Don't block the drive way of all the newbies in programming. :)

      R 1 Reply Last reply
      0
      • K klaydze

        try this: rs.Open "Select * from barcode Where barcodeid='" & txtbarcodeid.Text & "',con,1,3 if rs.eof then rs.addnew rs.fields("barcode")=text1.text rs.Update else // if existed msgbox "Record Existed" endif NOTE: make sure you have a "WHERE" to your SELECT so that you have a unique record to search.

        Don't block the drive way of all the newbies in programming. :)

        R Offline
        R Offline
        rrrriiizz
        wrote on last edited by
        #3

        thank u ya. it was working fine. thanks a lot

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups