473,797 Members | 3,152 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_BeforeUpda te(Cancel As Integer)

If Me.NewRecord Then

Me!displayedRun Number = Format(CLng(Nz( DMax("displayed RunNumber",
"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 2076
br***********@g mail.com wrote in
news:11******** *************@7 5g2000cwc.googl egroups.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_BeforeUpda te(Cancel As Integer)

If Me.NewRecord Then

Me!displayedRun Number =
Format(CLng(Nz( DMax("displayed RunNumber",
"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("displayed RunNumber","tab le", "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
3277
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 (Internationalized Domain Names / IDNA) which is something that I also need to support. The problem that I've been struggling with in .NET is that of Unicode Code Points > 0xFFFF. These points are encoded into UTF8 using the Surrogate Pair encoding scheme that...
2
4717
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 second field disappears. So it reads "1050-042" but i want it to be "1050-0402". The number 02 increases, so when it reaches 10+ it should be like "1050-0410".
5
2112
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 700001 700 002 700002 ..
2
1564
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 the following table layout: tblPatient ---------- REC: Autonum (Primary Key) KEY: Number (NOT UNIQUE)
5
1232
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 doesn't want to allow the different datatype.. The currency amounts are stored as number in the db... How can I accomplish this?
74
6456
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
1060
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 them.. the question was... Add a record to the list Remove a Record object from the list Find a Record object, given the last name View all Record objects. Make sure that your program is menu driven with an attractive user interface. i did...
2
2550
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 abc 2 def
3
2847
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 dataset to data in a second dataset, using a common key. I will first describe the problem in words and then I will show my code, which has most of the solution done already. I have built an ASP.NET that queries an Index Server and returns a...
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10469
Oralloy
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...
1
10209
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10023
tracyyun
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...
0
9066
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3750
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2934
bsmnconsultancy
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...

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.