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

text box generates auto number, need to save that number in a table

7
So I have downloaded this neat expression for a textbox control in a form that generates automatic sequence numbers with the 2-digit year in front of it:

=Format(Now(),"yy") & "CAR" & "-" & Left("000",4-Len(CStr([ID]))) & [ID]

(this is in the control source of the properties.)

so the result is: 07CAR-0002.... 07CAR-0003....

My question is: How do I save the generated numbers in the main table where I save all the relevant information from the form entry? It seems that the generated numbers stay with each form entry within the form but i need to store the number in a table for future reports.

Can anybody help, please?

JDV
Feb 2 '07 #1
5 4607
Rabbit
12,516 Expert Mod 8TB
Assuming that the form's record source is the table, just set the text box's control source to the field.

You may want to lock the field so they can't edit it.
Feb 2 '07 #2
I don't get it. You type =Format(Now(),"yy") & "CAR" & "-" & Left("000",4-Len(CStr([ID]))) & [ID] into the control source of the properties of a textbox and you get sequential numbers? I just get an error. Is ID a specified field in the table?
Feb 2 '07 #3
Rabbit
12,516 Expert Mod 8TB
From what I can tell, [Id] would have to be a field in the table. It would be [Id] that is generating an autonumber. The expression is merely autopopulating a different field.

Otherwise I don't know how that would generate sequential numbers by itself.
Feb 2 '07 #4
MMcCarthy
14,534 Expert Mod 8TB
So I have downloaded this neat expression for a textbox control in a form that generates automatic sequence numbers with the 2-digit year in front of it:

=Format(Now(),"yy") & "CAR" & "-" & Left("000",4-Len(CStr([ID]))) & [ID]

(this is in the control source of the properties.)

so the result is: 07CAR-0002.... 07CAR-0003....

My question is: How do I save the generated numbers in the main table where I save all the relevant information from the form entry? It seems that the generated numbers stay with each form entry within the form but i need to store the number in a table for future reports.

Can anybody help, please?

JDV
If you have a calculated control like this on the form then you can't also have it pointing to the field in the table.

One solution would be to set the control source of the textbox (txtSample) to the field in the table and put this calculation in an event of the form. The On current event would probably be best.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.  
  3.   Me.txtSample=Format(Now(),"yy") & "CAR" & "-" & Left("000",4-Len(CStr(Me.ID))) & Me.ID
  4.  
  5. End Sub
  6.  
Feb 3 '07 #5
NeoPa
32,556 Expert Mod 16PB
I don't get it. You type =Format(Now(),"yy") & "CAR" & "-" & Left("000",4-Len(CStr([ID]))) & [ID] into the control source of the properties of a textbox and you get sequential numbers? I just get an error. Is ID a specified field in the table?
That's because you're not doing it from within JDVon's form.
The [ID] field is already available in his recordset (IE Yes to your last question).
Feb 5 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Ward B | last post by:
Greetings. I'm somewhat new to this whole MySQL/PHP thing and need a little help. My web hosting service uses phpMyAdmin and at the bottom of the screen iis an area where I can upload a text...
6
by: Sebastien | last post by:
Hi, I am building a products database, linking sales and production. Each part has a unique sales Stock Code and Production Number. The sales stock code is a combination of letters and numbers...
3
by: Chris | last post by:
Before I started to create table, etc to track unique form field record number assigments I thought I'd check to see if there is now a better way to do this in .NET. I have a parent form (table)...
1
by: daniellee2006 | last post by:
I am creating a basic website to store people profiles and within this website i have a page that creates a table dependent on the number of records in mysql written in PHP within these tables...
9
by: sellcraig | last post by:
Microsoft access 2 tables table "data main" contains a field called "code" table "ddw1" is created from a make table query of "data main" Goal- the data in "code" field in needs to...
2
by: john | last post by:
Is it true that if I split my access database in backend and frontend and I implement custom auto increment for the ID fields, that my database is ready to be used in a multi-user environment? I...
4
by: laniebalbido | last post by:
hi , im a new in php. id like to know how to create a textbox that generates auto number for every new record to be inserted. thanks
2
by: markcarroll | last post by:
My company has a database on SQL server. I am tyring to make an access interface that will make a lot of things easier. I cannot change the database structure or the field types. I am trying to...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.