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

Generate Autonumber in Textfield On Form of Access

101 100+
hi,
i have to use the table(PRODUCTION) already generated in which all fields are of TEXT type.fields like (orderdate,palletno,customercode,itemno,pono,carto n,pcs,totalquantity)Now i have already some data in table like 7954 rows.Now when i open the form for entering details of new customer i want to generate new PalletNo (7955)automatically in TEXTFIELD(PalletNo_Text).Means whatever the last PalletNo in table +1.means i have the IDNO from 1-7954.Now i want to generate 7955.So what to do?
I already try this code but it is not working.

Private Sub Form_Load()
PalletNo_Text = Nz(DMax("[PalletNo]", "PRODUCTION") + 1)
End Sub

any solution appriciated.plz reply me as soon as possible.its urgent
Nov 19 '07 #1
5 8860
Megalog
378 Expert 256MB
Ok,
This may be a stupid question, but are you able to change the table? I would add an autonumber field (if all your palletno values truly are sequential, and unique already). I would just add the autonumber as a new field in the table, add a text box for it on the form, set the visible property to false, and then On_Current do:

Expand|Select|Wrap|Line Numbers
  1. If PalletNo_Text.value = "" then
  2.  PalletNo_Text.Value = YourNewAutoNumField.Value
  3. End if
Either way, I'd think adding that autonumber field as a genuine unique index and primary key would help things in general.

Ideally you'd want to just get rid of the duplicate information, and rename the new autonumber field to PalletNo.
Nov 19 '07 #2
billa856
101 100+
Sorry but i can't change the table,whenever i try to change it will show me that u can't change type because u have data in table.And my palletno are not sequntial in starting but after that it is, but they are unique.
So i only want that whatever is the last palletno in my table, i want to add next no in my form as palletno. is there any query or coding so that i can select the last pallatno of my table.and generate next no to that palletno.?pls reply me
Nov 19 '07 #3
missinglinq
3,532 Expert 2GB
You say that all fields are text, so I think you need to make [PalletNo] numeric in order to find DMax! I've used something like this successfully

Nz(DMax("val([PalletNo])", "PRODUCTION") + 1)

And a true AutoNumber, which is to say one generated automatically by Access, is, as John Vinson, MVP says, not fit for human comsumption! They should be left for Access to use for its internal housekeeping, and numbers for purposes such as we are addressing here should be generated just as we're doing here!

And to both of you, Welcome to TheScripts!

Linq ;0)>
Nov 19 '07 #4
billa856
101 100+
Hey thanks Buddy now its working.
Again thank you both very much for ur help.
Nov 20 '07 #5
missinglinq
3,532 Expert 2GB
Glad we could help!

Linq ;0)>
Nov 20 '07 #6

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

Similar topics

2
by: Oliver Gabriel | last post by:
hello, i have a form with a table on its back. The primary key is an autonumber field called "ID". I have a textfield displaying the value of this field (just for my info, data is sure entered...
2
by: jmpinto | last post by:
I have a field on a form that I would like to automatically generate a number, in sequential order, each time a new record is created, and be stored in a field. The problem is that I do not want...
0
by: Richard Gregory | last post by:
Hi, I have the wsdl below, for an Axis web service, and when I select Add Web Refernce in Visual Studio the proxy is missing a class representing the returnedElementsType (see reference.cs below...
6
by: AA Arens | last post by:
Hi, I have a database with 2 main forms. Contacts and companies. I share the base with two others via LAN. On the companies form I have buttons to navigate throught the records (>400). We are...
11
by: Alan Mailer | last post by:
A project I'm working on is going to use VB6 as a front end. The back end is going to be pre-existing MS Access 2002 database tables which already have records in them *but do not have any...
7
by: pltmcs | last post by:
I am trying to generate some records from one table into another. The problem is that the new table has an autonumber field (PID). The PID is part of the primary key since it is possible to have...
2
by: shiznaw | last post by:
So, umm. How would you generate an alpha-numeric autonumber each time an end user clicks a field/button on a form without using the autonumber option within a table.
2
by: ketanlad | last post by:
Hi, I am trying to generate a autonumber function in access without using the Autonumber datatype field. I have limited knowledge of access and I have been advised by looking on the web that I...
6
by: ashes | last post by:
Hi, I am creating an ecommerce website using Microsoft Visual Studio, VB.Net and MS Access 2003. I am new to VB.Net When someone wants to register on the website, they fill out a form and the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.