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. extracting new autonumber from database

extracting new autonumber from database

Scheduled Pinned Locked Moved Visual Basic
databasequestion
2 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.
  • M Offline
    M Offline
    mcm
    wrote on last edited by
    #1

    Dim rSQL As String Dim intID As Integer rSQL = "Select Max(OrderNumber) from OrderGenerate" Set RS = Conn.Execute(rSQL) intID = RS.RecordCount + 1 txtOrderNo.Text = intID the objective of the above code is to abstract a new OrderNumber from the OrderGenerate table in Access. (OrderNumber is an Autonumber). However, when run, the textbox just show 0 all the time, even tho it should show the current OrderNumber + 1. Why is this? Thank you!

    N 1 Reply Last reply
    0
    • M mcm

      Dim rSQL As String Dim intID As Integer rSQL = "Select Max(OrderNumber) from OrderGenerate" Set RS = Conn.Execute(rSQL) intID = RS.RecordCount + 1 txtOrderNo.Text = intID the objective of the above code is to abstract a new OrderNumber from the OrderGenerate table in Access. (OrderNumber is an Autonumber). However, when run, the textbox just show 0 all the time, even tho it should show the current OrderNumber + 1. Why is this? Thank you!

      N Offline
      N Offline
      Nick Seng
      wrote on last edited by
      #2

      I'm not sure why the textbox is showing 0, but looking from your SQL Statement,"Select Max(OrderNumber) from OrderGenerate" ,would only return 1 row, the maximum(largest) OrderNumber.Then RS.RecordCount would only return 1, thus your textbox would always remain "2" Notorious SMC


      The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
      Get your facts first, and then you can distort them as much as you please Mark Twain

      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