473,386 Members | 1,715 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,386 software developers and data experts.

Combining a Number and a String

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 below) The run
number increments in each new record, the 06 will only update at the
begining of the new year. I originally made it this way because the
user only sees "060004", it makes no difference to them if its actually
two text boxes or not.

1 Part: problem is I now realize that I need to be able to go back and
find a particular run number, such as search for "060004". I need to
create a seperate field that adds those to fields together (well not
add but "join" them together).

The code for the year is a Default Value set in the table to:

=Right(Str(Year(Now())),2)

The code for the run number is a beforeupdate code in the form.. People
have questioned this but I like it because the user doesnt get a Run
Number until they complete the entire form, basically they need the
number before they go home so it forces them to fill out the record
right. The code is as follows:

Private Sub Form_BeforeUpdate(Cancel As Integer)

If Me.NewRecord Then

Me!displayedRunNumber = Format(CLng(Nz(DMax("displayedRunNumber",
"fields"), "0")) + 1, "0000")

End If
End Sub

Part 2 Problem: I just realized... come 2007 the number 06 will update
to 07, but the run number will just keep incrementing. I need it to
reset down to 0001, so the new number will appear 070001. I realize
this may require some code revising.

I would be really greatful if someone could walk me through these
changes, much of the work seen from above was the result of much help
from many people in these forms. So if you have an idea on how to fix
these problems please be specific because I am very new to all this
access stuff, but I must admit its fun.

Thanks so much in advance

Brad G.

Aug 2 '06 #1
1 2060
br***********@gmail.com wrote in
news:11*********************@75g2000cwc.googlegrou ps.com:
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 below) The run number increments in each new
record, the 06 will only update at the begining of the new
year. I originally made it this way because the user only sees
"060004", it makes no difference to them if its actually two
text boxes or not.

1 Part: problem is I now realize that I need to be able to go
back and find a particular run number, such as search for
"060004". I need to create a seperate field that adds those to
fields together (well not add but "join" them together).

The code for the year is a Default Value set in the table to:

=Right(Str(Year(Now())),2)

The code for the run number is a beforeupdate code in the
form.. People have questioned this but I like it because the
user doesnt get a Run Number until they complete the entire
form, basically they need the number before they go home so it
forces them to fill out the record right. The code is as
follows:

Private Sub Form_BeforeUpdate(Cancel As Integer)

If Me.NewRecord Then

Me!displayedRunNumber =
Format(CLng(Nz(DMax("displayedRunNumber",
"fields"), "0")) + 1, "0000")

End If
End Sub

Part 2 Problem: I just realized... come 2007 the number 06
will update to 07, but the run number will just keep
incrementing. I need it to reset down to 0001, so the new
number will appear 070001. I realize this may require some
code revising.

I would be really greatful if someone could walk me through
these changes, much of the work seen from above was the result
of much help from many people in these forms. So if you have
an idea on how to fix these problems please be specific
because I am very new to all this access stuff, but I must
admit its fun.

Thanks so much in advance

Brad G.
Part 1: to concatenate two text strings, just use the
concatenation operator &
text1 & text2 will give text1text2

For part 2, you put a test in the DMAX function so that it
returns the max for the given year.
Dmax("displayedRunNumber","table", "yearfield = '" & mid(cstr
(year(now())),3,2) & "'"

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Aug 2 '06 #2

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

Similar topics

2
by: Chris Mullins | last post by:
I've spent a bit of time over the last year trying to implement RFC 3454 (Preparation of Internationalized Strings, aka 'StringPrep'). This RFC is also a dependency for RFC 3491...
2
by: Kristian | last post by:
Hey, I have some problems combining 2 fields in a query. For example: the first field is "1050-04" and the second field is "02". However, when i try to combine these two the zero in the...
5
by: M.Stanley | last post by:
Hi, I'm attempting to create a query that will combine 2 columns of numbers into one. The followng comes from 1 table with 4 fields (A,B,C,D) A B RESULT 700 000 700000 700 001 ...
2
by: Max | last post by:
Hello everyone, I have a task of combining two tables: tblPatient and tblSolution, related by a KEY field in a one-to-many relationship from tbl Patient to tblSolution, respectively. So, I have...
5
by: drdave | last post by:
Hi, In a bound column I have currency datatypes, but the client does not like $ 0.00 and wants to show a blank instead.. I'm trying to use an if statement to write out string.empty but it...
74
by: Beany | last post by:
Hi, I have got an ADD button with the following code: Private Sub addrec_Click() On Error GoTo Err_addrec_Click DoCmd.GoToRecord , , acNewRec Exit_addrec_Click:
0
by: ahmetburhan | last post by:
hi there, how are you doing all? i am a beginner user in c++ our teacher asked some question i did the first part... and i have donw something similar for second part but i dont know how to combine...
2
by: rpeacock | last post by:
I have a function that takes a field with values separated by commas within the field and splits them to multiple rows. Example: Field - Interior Value - abc,def,efg,ghi Output: ID Item 1 ...
3
by: Ken Fine | last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets and DataTables should be able to answer fairly easily. The basic question is how I can efficiently match data from one...
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.