Solved

Reference number generator for access

Posted on 2006-11-09
6
212 Views
Last Modified: 2010-04-30
Hi All,

I need to find a way of generating a Number to go in to a text box in access.
the first number has to be based on the date, the numbers after that can be anything.

i,e. "SMP1-1117"

The first number comes from the date, if it is April it is SMP1, May would be SMP2.
April = SMP1
May = SMP2
June = SMP3
July = SMP4
August = SMP5
September = SMP6
October = SMP7
November = SMP8
December = SMP9

The name of the text box it goes in to is "Text50" any help would be great guys.

Thanks so Much.
0
Comment
Question by:pnorris99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 1

Author Comment

by:pnorris99
ID: 17905248
What I had come up with initially was,

Private Sub Text50_Click()

If Calendar1 >= ("01/11/2006") And Calendar1 < ("31/11/2006") Then

Text50 = "test"

End If

End Sub

I was going to use multiple IF statements for the different months.

I have also just thought would it be possible to have the script pick up the year and enter it in the Reference.
So it would be SMP1-06??     ??=Random number.

PS, I will update the point shortly, I am not stingy lol, I am just having bother with my card lol.

Thanks again guys.
0
 
LVL 1

Author Comment

by:pnorris99
ID: 17905269
I increased the points now to a more reasonable amount.
0
 
LVL 15

Expert Comment

by:cquinn
ID: 17905751
Private Sub Text50_Click()

If Calendar1 >= ("01/11/2006") And Calendar1 < ("31/11/2006") Then

Text50 = "SMP" & cStr(Month(Calendar1) -3)

End If

End Sub
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 15

Expert Comment

by:cquinn
ID: 17905754
Opps - left some extraneous code in

Private Sub Text50_Click()

Text50 = "SMP" & cStr(Month(Calendar1) -3)

End Sub
0
 
LVL 1

Author Comment

by:pnorris99
ID: 17906941
Hi Mate thanks for that I have changed it a little to input the year also, do you know of a way displaying a 2 digit year i,e. YY rather than YYYY.

Also do you know of a way to create 2 extra digits on the end of this text that count up in 1's.

I am assuming this will be a little complicated as it is going to need to know what the last number was in order to add 1 to it.

SMP8-06-000  then the next record would be SMP8-06-001


Thanks again,

Private Sub Text50_Click()

Text50 = "SMP-" & cStr(Month(Calendar1) -3) & cStr(Year(Calendar1)) & "-"

End Sub
0
 
LVL 15

Accepted Solution

by:
cquinn earned 500 total points
ID: 17910320

Private Sub Text50_Click()

Text50 = "SMP-" & cStr(Month(Calendar1) -3) & Format(Calendar1,"yy")) & "-"

End Sub
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question