Generate sequencial number in a BO


Author
Message
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi All,

I have several form which will show a list with a sequential order number like 1,2,3,4, etc.  (See picture below).  I want this field LineOrder to be autogenerated with the next unused value when a new record is created, so if the last one used is 5, then when clicking New, the value will be 6.

I added the following code in the PaymentMethodBO.vb:

Private Sub PaymentMethod_SetDefaultValues()

     ' --- Calculate the next LineOrder number to be added as a default value for Me.LineOrder field.

     Me.MoveLast() ' This will move the record pointer to the last record, in this case the new one.

     Me.MovePrevious() ' Go back to the previous record which should be the last one.

     Dim nextLineOrder As Integer = 0

     nextLineOrder = Me.LineOrder + 1 ' Increment 1 to get the next default value.

     If nextLineOrder = 0 Then

          nextLineOrder = 1

     End If

     Me.MoveLast() ' Go back to the new record

     ' Set the default Value here

     Me.LineOrder = nextLineOrder

End Sub

So far this is working fine, but I would like to make sure this is the proper way to get this done when working with data in the BO.  I guess I may have another BO with a SELECT MAX() statement to get the last value used and then increment this value.  So I would appreciate any recommendation in this regard.

Thanks!Smile

Edhy Rijo

Reply
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Yeah, I noticed the same thing... *scratching head* BigGrin  I don't have a lot of time to dedicate to this at the moment, but I know that it is possible, so I will have to add this to the "to-look-at" list.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Edhy Rijo - 17 Years Ago
Greg McGuffey - 17 Years Ago
Edhy Rijo - 17 Years Ago
Edhy Rijo - 17 Years Ago
                     I might make a couple of suggestions:

- You don't need to...
Greg McGuffey - 17 Years Ago
                         [quote][b]Greg McGuffey (03/19/2008)[/b][hr] - When the BO is created...
Edhy Rijo - 17 Years Ago
                             Looking good Edhy!

The FieldNames is an enum that is...
Greg McGuffey - 17 Years Ago
                                 Looks good...as long as you don't plan on two people hitting this...
Trent L. Taylor - 17 Years Ago
                                     Hi Trent, For now these tables will be used initially in the...
Edhy Rijo - 17 Years Ago
                                         [quote] I don't know if with SQL2005 you can have as many...
Trent L. Taylor - 17 Years Ago
                                             Hi Trent, Regarding an Invoice ID which is a unique number and how...
Doron Farber - 17 Years Ago
                                                 If you want SQL Server to generate it, just create the column as...
Trent L. Taylor - 17 Years Ago
                                                     Hi Trent, But I have alreadyPK field that is an Auto Increment, and...
Doron Farber - 17 Years Ago
                                                         Sure you can ;) You can have as many identity columns as you would...
Trent L. Taylor - 17 Years Ago
                                                             Ok Trent, But when I change the Identity to Yes in the TransactionNo...
Doron Farber - 17 Years Ago
                                                                 Here is a primary key column with an identity (auto-increment)...
Trent L. Taylor - 17 Years Ago
                                                                     Hi Trent, Thanks for your reply. Yes I see that you can have the...
Doron Farber - 17 Years Ago
                                                                         No. Actually you can do the very same thing through SSMS (SQL Server...
Trent L. Taylor - 17 Years Ago
                                                                             Hi Trent, Thanks for your reply and please see this small video of...
Doron Farber - 17 Years Ago
                                                                                 Here would be my suggestion. Instead of fighting all of that, just...
Trent L. Taylor - 17 Years Ago
                                                                                 Well, I would have sworn Trent was right on this one. But I just...
Greg McGuffey - 17 Years Ago
                                                                                     Er...I mean one of Trent's other suggestions...can't see straight this...
Greg McGuffey - 17 Years Ago
                                                                                         Yeah, I noticed the same thing... *scratching head*:D I don't have a...
Trent L. Taylor - 17 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search