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