Rollback on escape in form?

Hi again,

sorry of course it is more important just been in the middle of some other things thats all..
The way I got it set up is I have a "Orders" Table wich is "OrderHeader" from there I go to OrdTimes to record TimesSpent on a "Order"
and another Orders to OrdExp which holds Expenses related to the "Order"

Ordes is then Linked to "Invoices" and "Invoices" to "InvDetails"

Here I am still not exactly sure how to link that correctly but that is a different question all together :-)

I will look into all of your suggestions thanks alot for you input!"

Cheers
 
Not sure whether you were addressing me?
If you were, I don't know which other thread you mean

Yes thanks Isladogs,

the approach of getting information from subform to subform from Header


maybe someone does know how to approach that?

Cheers
 
going back to my 500,000 "tickets".
if the OP is creating 100 Orders Per Day, in 1 Year time (x 365 days),
he need 36,500 ticket numbers in 1 Year.
Now divide Half million (500,000) by this number to get how many
years this ticket will last:
?500000 / 36500 = 13.7 Years.
with that years this db might already been migrated to another system.

100 orders per day! that is a busy shop, when ideally you only create 4 to 6 per day?
Yes I did say it would only be an issue in the distant future but so was the Year2K bug when programmers first became aware of a future problem.
But that's by far the least of my three objections.

Do tell me how all that code is better than my one-line DMax code.
What does your version do that mine doesn't ...or what does it do better?
 
Yes thanks Isladogs,

the approach of getting information from subform to subform from Header


maybe someone does know how to approach that?

Cheers
Sorry - not me.
I never use navigation forms as they can be very difficult to work with if you need to do anything more than basic functionality.
It isn't difficult to replicate many of the features with an emulated navigation form which is also easier to modify

For example, this is from my automatic form resizing (AFR) example app:

1660485119928.png


If you are interested in looking at that, see my article:
 
But that's by far the least of my three objections.
if you object, don't use i am not offering it to you and i am not forcing anybody to use it.
Do tell me how all that code is better than my one-line DMax code.
simple as this, it prevents "gap".
also, when user decided to archive old Orders to history db and
remove the records (all closed ones), how can you Dmax() when also
the "last max" record has been deleted?
 
if you object, don't use i am not offering it to you and i am not forcing anybody to use it.

simple as this, it prevents "gap".
also, when user decided to archive old Orders to history db and
remove the records (all closed ones), how can you Dmax() when also
the "last max" record has been deleted?

You really shouldn't take comments about your example personally.
Whether or not I would use your code is completely irrelevant.
I'm perfectly happy to use ' clever' code where there is no easier alternative ... but not just for its own sake.

My intention is to just suggest simpler alternatives for the OP that work equally well for the purpose.

The approach I suggested using DMax would also prevent any 'gaps' in the order number.
As mentioned in post #19, it is true that if all the records were deleted/archived or even the last order number were deleted, the next order number(s) would repeat earlier number(s)

However there are 2 alternative approaches that solve that issue and work equally well
a) Version2 - Table:
Use a single record table tblLastOrder to store the last order number and use this slightly modified code in the control OnDirty event:

Code:
Private Sub Date_Dirty(Cancel As Integer)
    Me.OrderNumber = Nz(DLookup("LastOrderNo", "tblLastOrder"), 0) + 1
   
    CurrentDb.Execute "UPDATE tblLastOrder SET tblLastOrder.LastOrderNo = [LastOrderNo]+1" & _
        " WHERE (((tblLastOrder.ID)=1));"

End Sub

b) Version 3 - Property
Better still, create a custom property LastOrderNo with long integer datatype and reference that as follows:

Code:
Private Sub Date_Dirty(Cancel As Integer)
    'get the LastOrderNo property & add 1
    Me.OrderNumber = GetProperty("LastOrderNo", 0) + 1
   
    'update the LastOrderNo property value
   SetProperty "LastOrderNo", 4, Me.OrderNumber

End Sub

Both GetProperty & SetProperty are standard code in the module modProps

Both methods are fast and prevent any gaps even if previous records are archived/deleted
The file size is in each case <500 kB
The only limits to the number of orders is the long integer limit of 2147483647

Using your example of 100 orders per day, the code will work for about 58,835 years.
Even for 1 million orders / day (Amazon?), it will work for almost 59 years!
I expect Access will have shuffled off into the sunset long before then

If even that's not long enough use e.g. double or bigint datatype instead of long
 

Attachments

I guess I started some discussions about this topic :oops:

But thanks for the Input from all of you guys!

I will look into it!

Many thanks to all
 
Thanks Pat I will take that also into account but need to work through all of what has been suggested.

Many thanks again to all of the input from you guys!

Cheers
 

Users who are viewing this thread

Back
Top Bottom