From: Emma on 23 Apr 2010 14:41 I no I don't need an auto number but basically what I need is a number that counts sequentially 1-[1st month end number] then starts over again for the next month ie 1- [next month end number]. The field and column name is [Financial ID].... I was thinking something like: Private Sub Form_Before Update(Cancel as Integer) If Me.NewRecord and Month([DateofLoanAgreement])=Month(Now()) then Me![Financial ID] = Now() + Nz(DMax( "[Financial ID]", "[Loans - Table]"])+1 End If End Sub I know it's all very confusing but maybe someone could help me organize this so it makes sense? Not sure if I can put Now90's date in front of the auto number? Or if I should be using the format?
From: Jeff Boyce on 23 Apr 2010 18:15 Emma You do not need to actually store a "number" (it isn't a number, you know, because you won't do any math on it) like that (and it's rarely necessary). Storing more than one fact in a single field (your sequence number, a "dash", and your [month end number]) is not good design. Moreover, what happens NEXT year when you have another month "04"?! By all means, do a search on-line for "custom autonumber" to get some ideas on how to build a procedure that gives you sequential number. But decide how to handle the same month happening year after year, and then look into using a query to concatenate together the pieces you need to display -- e.g., your expression might look something like: YourNewExpression: [YourSequenceField] & " - " & {YourYearMonthValue} Good luck! Regards Jeff Boyce Microsoft Access MVP -- Disclaimer: This author may have received products and services mentioned in this post. Mention and/or description of a product or service herein does not constitute endorsement thereof. Any code or pseudocode included in this post is offered "as is", with no guarantee as to suitability. You can thank the FTC of the USA for making this disclaimer possible/necessary. "Emma" <Emma(a)discussions.microsoft.com> wrote in message news:1BAA8269-6F83-41F2-8E16-27155E5328B4(a)microsoft.com... >I no I don't need an auto number but basically what I need is a number that > counts sequentially 1-[1st month end number] then starts over again for > the > next month ie 1- [next month end number]. The field and column name is > [Financial ID].... I was thinking something like: > > Private Sub Form_Before Update(Cancel as Integer) > If Me.NewRecord and Month([DateofLoanAgreement])=Month(Now()) then > Me![Financial ID] = Now() + Nz(DMax( "[Financial ID]", "[Loans - > Table]"])+1 > End If > End Sub > > I know it's all very confusing but maybe someone could help me organize > this > so it makes sense? Not sure if I can put Now90's date in front of the auto > number? Or if I should be using the format? >
|
Pages: 1 Prev: if all items in listbox are the same Next: Run-time error 3426 |