Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 27th, 2005, 11:59 PM
Authorized User
 
Join Date: Mar 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi SerranoG,
Thanks for your reply.
I have to put it backwords because in the default value in the property of that textbox I set it as "=GetNextNum()" and then I save the newly generated document number in [DocNo] from "receive" table. (which means i set the control source to DocNo from "receive" table)
I notice that when i save it, the DocNo is look like "A00001"
when the sql reselect the DocNo again for the next new number it will get "A00001" as the DocNo in DMax,
so is it the "A" and "00001" cannot put together as the DMax will only able to add the numbers only but not include the "A"?
i try to declare all as variant but wont works.
any way to solve this problem?
thanks a lot ...

 
Old March 28th, 2005, 12:25 AM
Registered User
 
Join Date: Mar 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi friend
  all thru discussion u have got a method to generate a auto genration of strings method
  but then hw wud to adjust that number when it comes to value 10
  wud it be A000010 or A00010 ???


the simple principle to generate auto ids is

first take max id using select statement
then use substr function take all numbers from 2nd position for the id
convert it then to integer(since it will be in string)
then add one to it and store in a numberis variable say t1
now find number of digits in that numberic value t1
then subtract it from 5 since u have five 0's n store it in numberic variable t2
now atlast in temp_str string variable concat first letter A and then use some replicate function for zeros(here use t2 variable for number of times the 0's has to be repeated) atlast add that t1 variable to generate actual auto generated string value

hope it helps




 
Old March 28th, 2005, 12:42 AM
Authorized User
 
Join Date: Mar 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by savi317
 hi friend
all thru discussion u have got a method to generate a auto genration of strings method
but then hw wud to adjust that number when it comes to value 10
wud it be A000010 or A00010 ???
hi savi317,
Thanks for your reply.
For yr question, it would be A00010.
Basically i know what are you talking about in that principle. I am a new learner of access so I still dont know what I have to do with all those VBA codings. Anyway i will try to think about it. Thank you very much for yr suggestion.

Cheers

 
Old March 28th, 2005, 12:39 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I would say that it is a bad idea to use an autonumber field for any actual data.
The autonumber should be used only for automatically uniquely identifying a particular record to the machine itself.
To uniquely [u]name</u> a record (including serializing that record) you should write code to generate that unique “name” yourself, following whatever business rules you build in.
In this way, you can format it according to your desires, you can delete a record without having a resultant gap in your numbering (if you so desire), and so on.
The autonumber should not be used as data that humans are going to interact with.





Similar Threads
Thread Thread Starter Forum Replies Last Post
AutoNumber causes problem. myself Classic ASP Professional 1 July 10th, 2006 03:35 PM
AutoNumber field tulincim Access 5 June 6th, 2006 03:44 PM
AutoNumber Hell somissac Access VBA 5 March 22nd, 2005 04:05 AM
Autonumber display in form field ianc Access 2 January 14th, 2005 07:11 AM
regarding Autonumber... MuthuAL Classic ASP Databases 2 December 8th, 2004 08:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.