Hello All
First of all I am an access newbie and I am looking for a bit of help on this. I have looked at other similar articles but I a failing in my implementation.
I have an number generated automatically using this code - Private Sub Form_Dirty(Cancel As Integer)
-
Me![ReportID].Value = (DMax("ReportID", "Reports") + 1)
-
End Sub
The number format is as follows BR then year(=Format(Da te(),"""BR""yy" )001
EG BR08 001
What I would like to do is reset the number to zero when the year changes.
I appreciate all your guidance
Regards
Joe
2 1994 Rabbit 12,516
Recognized Expert Moderator MVP
Hello All
First of all I am an access newbie and I am looking for a bit of help on this. I have looked at other similar articles but I a failing in my implementation.
I have an number generated automatically using this code - Private Sub Form_Dirty(Cancel As Integer)
-
Me![ReportID].Value = (DMax("ReportID", "Reports") + 1)
-
End Sub
The number format is as follows BR then year(=Format(Da te(),"""BR""yy" )001
EG BR08 001
What I would like to do is reset the number to zero when the year changes.
I appreciate all your guidance
Regards
Joe
Please use code tags.
You need to toss in an extra argument to account for the year.
Something along the lines of: - Private Sub Form_Dirty(Cancel As Integer)
-
Me![ReportID].Value = (DMax("ReportID", "Reports", "ReportYear=Year(Date())") + 1)
-
End Sub
Which means of course that you'll need some variable that holds the Year in some format.
ADezii 8,834
Recognized Expert Expert
Hello All
First of all I am an access newbie and I am looking for a bit of help on this. I have looked at other similar articles but I a failing in my implementation.
I have an number generated automatically using this code - Private Sub Form_Dirty(Cancel As Integer)
-
Me![ReportID].Value = (DMax("ReportID", "Reports") + 1)
-
End Sub
The number format is as follows BR then year(=Format(Da te(),"""BR""yy" )001
EG BR08 001
What I would like to do is reset the number to zero when the year changes.
I appreciate all your guidance
Regards
Joe
To allow for the Year change, keep the 3-digit formatting, then Reset/Generate the next consecutive Report ID, try: -
Dim strLastEntry As String, strLastEntryYear, strNextEntry As String
-
-
strLastEntry = "BR07 512" 'Obtained from the Dax() Function.
-
strLastEntryYear = Mid$(strLastEntry, 3, 2)
-
-
If strLastEntryYear = Format$(Date, "yy") Then
-
strNextEntry = Left$(strLastEntry, 5) & Format$(Val(Right$(strLastEntry, 3)) + 1, "000")
-
Else
-
strNextEntry = Left$(strLastEntry, 2) & strLastEntryYear & " 000"
-
End If
-
-
Me![ReportID].Value = strNextEntry
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Shuffs |
last post by:
Could someone, anyone please tell me what I need to amend, to get this
function to take Sunday as the first day of the week?
I amended the Weekday parts to vbSunday (in my code, not the code
attached), yet when I ran it for 28/09/2003 (UK date format) it
returned Week 39. I would have expected it to return Week 40.
However, I'm really stuck and my head is busting over this, so any
pointers would be gratefully appreciated.
Many thanks...
|
by: Nathan Sokalski |
last post by:
I have a user control that contains three variables which are accessed through public properties. They are declared immediately below the "Web Form Designer Generated Code" section. Every time an event is fired by one of the controls contained in the User Control, these variable are reset. Here is my current code (I have a little more to add later, right now I am just concerned about the variables getting reset):
Public Class DatePicker2...
|
by: Kd |
last post by:
I have the OrderNo set as the following
Right(Format(Date(),"yyyy"),1) & Format(Date(),"mm") &
"-"Format(,"000")+1
This works great until
I get to a new month and need the numbers to reset like the following
example
512-001
Anybody have any thoughts to point me in the right direction,got stuck
with making updates to someone elses created database and getting
frustrated.
|
by: Kd |
last post by:
I have the following set up to give me aresponse number R05-001
I would like it to reset to R06-001 at new year
ResponseNo: "R" & Right(Format(Date(),"yyyy"),2) & "-" &
Format(,"000")
This is an expression in a query
any help is apprecieated
Ken
|
by: brad.goldberg |
last post by:
2 Part question for you all, seems kinda tricky to me, but many of you
are access gods compared to myself.
Here's the deal... I have a label on my form called Run Number:
Next to it I have a small text box that displayed the current truncated
year "06". Immediately next to it, there is a second text box that
displayes the actual run number, for example "0004", this number is
effectively being stored as a string (I think, see code...
| |
by: cansnowboard |
last post by:
I built a file management database which generates a file number based on the year.
i.e. 2006-PRRS-13
The criteria was that each file should be unique. So I took the primary key, added one to it and moved on.
Several months down the road they came back and said did we mention the file number needs to reset to zero each year.
They click a button to generate the file number.
|
by: cassey14 |
last post by:
Hi Guys...
Im doing a system and it really make my head ache..i hope somebody help me..
I need to have an id like this "ABCD-07-000001"... I dont know how will I work on that thing.. ABCD always a default character..07 is the last two digit of the year and it should be reset everytime a year change..and the last six digit should be incremented by 1 everytime they add a new record but it should be reset when the year change..please help me...
|
by: tdw |
last post by:
In my Orders database (which someone else created and I have been improving), when I enter a new order it generates a file number (i.e. 2007-0001) using an autonumber REC_ID field. I'll show you the code that it uses.
The following occurs upon a button click:
If Me! <> 0 And Me! = "" Then
DoCmd.SetWarnings False
If Me! - 10493 < 10 Then ' Numeric Value 10493 is last value of rec_id upon year change for file_id renum
...
|
by: Vince |
last post by:
Given a week Number, how do I calculate the date that for the Monday
of that week?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |