473,382 Members | 1,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Concatanation

I have a question,

I want to build a JobNo made up from the YY part of the date on my form then
with a "/" and then the month followed by a counter field.
Something like this

03/11698 (03 = Year, /, 11= month, 698 counter)

Any ideas please

Thanks
Nov 12 '05 #1
2 1777
Try this..
Format(Date(),"yy/mm") & 698

Substitute your form references for Date() and of course the counter
field.

- Jim

On Mon, 24 Nov 2003 20:15:29 +0200, "home" <re**@telkomsa.net> wrote:
I have a question,

I want to build a JobNo made up from the YY part of the date on my form then
with a "/" and then the month followed by a counter field.
Something like this

03/11698 (03 = Year, /, 11= month, 698 counter)

Any ideas please

Thanks


Nov 12 '05 #2
On Mon, 24 Nov 2003 20:15:29 +0200 in comp.databases.ms-access, "home"
<re**@telkomsa.net> wrote:
I have a question,

I want to build a JobNo made up from the YY part of the date on my form then
with a "/" and then the month followed by a counter field.
Something like this

03/11698 (03 = Year, /, 11= month, 698 counter)

Any ideas please


The Easy bit:

Sub Form_BeforeUpdate(Cancel As Integer)
' or could be BeforeInsert, if you like
If IsNull(Me!JobNo ) Then
Me!JobNo = format(JobDate,"YY/MM") & GetCounter(JobDate)
End If
End Sub

The hard bit: working out a counter.
(warning: air code - untested)

Function GetCounter(pDate As Date)
' assumes a table called "tblJobNo" with fields:-
' YearMonth : Text 5 - Primary Key
' TheCounter: Long Integer

' also assumes DAO.

Dim rs as recordset, db as database, i as long
set db = currentdb()
' next line may wrap in newsreader
set rs = db.openrecordset("select * from tblJobNo where YearMonth =
'" & Format(pDate,"YY/MM") & "'")
with rs
if .eof then
.addnew
!YearMonth = Format(pDate,"YY/MM")
i=0
else
i = !theCounter
.Edit
end if
i = i + 1
!TheCounter = i
.update
.close
end with
set rs=nothing
set db =nothing
GetCounter = i
' maybe GetCounter = Format(i,"000")
End Function

Add error trapping to suit. Also some locking options on OpenRecordset
method (dbDenyRead or dbDenyWrite but I forget which parameter). ADO
would require a slight difference in the opening of the recordset but
the rest of the code would be the same.
--
A)bort, R)etry, I)nfluence with large hammer.
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ken in Melbourne Australia | last post by:
If I use the curly bracket syntax (referred to as the complex syntax) within a string, how do I get to call a function within it? The php manual says that the first (or previous) character for...
3
by: Paul Smith | last post by:
I have having trouble building a strong which I want to be the body of an Email. I have the code worked out which send the email but I cannot understand why I cannot seem to concatenate a string...
8
by: zorro | last post by:
I need to read the entire eventlog and parse it. The application uses vb.net and the EventLog object. The problem i'm having is that it can take less then a second up to 15 seconds to read all...
7
by: Martin Marques | last post by:
Is it posible to do string concatanation in plpgsql? Somthing like: sec := ''some string here'' . NEW.id; Is there a way to do this? I need te value of that new string for things that come...
3
by: Rahul Gupta | last post by:
I want to have certian key combinations which are hidden from user but if required i can use them to add some additional functionality to the program. I want to do this in C# 2.0 and i am using...
4
by: jim | last post by:
I'm trying to import a 625MB, tab-delimited .txt file into Access, but I keep receiving the following error after several minutes of what seem to be noble attempts by Access to render the data: ...
7
by: tirrell payton | last post by:
Hello, I am attempting to validate my user's email addresses by sending them a link. However, I am having trouble concatenating the variable name (GUID) into the url. Im using C#: public...
122
by: C.L. | last post by:
I was looking for a function or method that would return the index to the first matching element in a list. Coming from a C++ STL background, I thought it might be called "find". My first stop was...
1
by: SilRay | last post by:
I will admit up front that this is to help with an assignment for a class, however, I'm looking for information outside the scope of the assignment because I want to do something cooler. The...
2
iam_clint
by: iam_clint | last post by:
Hello everyone I'm still learning vb.net and I'm stuck on something. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.