473,549 Members | 5,196 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

auto generate claim no

Dear Gurus,

i had written following codes to auto generate the next claim no

Private Const strC = "GCT/02/J/"
Private Sub Command1_Click( )
Dim stra, stre As String
Dim intb, intd As Integer
Dim strd As String
stra = "200"
intb = Val(stra) + 1
intd = Len(CStr(intb))
stre = String(4 - intd, "0") & CStr(intb)
MsgBox strC & stre
End Sub

now the issue is that based on last claim no. when the forms load, we
wants to generate a new no and insert table/add as new record. say we
have serial

GCT/02/J/001,GCT/02/J/002,GCT/02/J/003...SO ON so the new ID will be
GCT/02/J/004
so can any one put highlights how to do this...

regards,
shahzad

Nov 13 '05 #1
2 2267
Hi,

SalimShahzad wrote:
Dim stra, stre As String
Dim intb, intd As Integer
BTW - with the above, you'll declare stra and intb as variants. Your way is
feasible with i.e. VB.Net but not with VBA/VB...6. There you'll have to
define each variable even if they're delimited by a comma, as in:

Dim stra As String, stre As String
Dim intb As Integer, intd As Integer
now the issue is that based on last claim no. when the forms load, we
wants to generate a new no and insert table/add as new record. say we
have serial

GCT/02/J/001,GCT/02/J/002,GCT/02/J/003...SO ON so the new ID will be
GCT/02/J/004
so can any one put highlights how to do this...


Basically, I'd solve that with something like this:

Function getNext(ByVal strLast As String) As String
Dim strLeaveAlone As String
Dim intNextNo As Integer
strLeaveAlone = Left(strLast, Len(strLast) - _
InStr(1, StrReverse(strL ast), "/") + 1)
intNextNo = CInt(Mid(strLas t, Len(strLeaveAlo ne) + 1))
getNext = strLeaveAlone & Format(intNextN o + 1, "000")
End Function

The above will use the last occurance of "/" to find the numeric part.
You might also want to check out the split-function (in your case,
split(strLast, "/")(3) would give you the numeric part at the end) which is
available from A2K on (as is the strReverse-function).

Cheers,
Olaf [MVP]
--
My .02: www.Resources.IntuiDev.com
Nov 13 '05 #2
On 2 Feb 2005 05:00:56 -0800, "SalimShahz ad" <sa**********@g mail.com>
wrote:
Dear Gurus,

i had written following codes to auto generate the next claim no

Private Const strC = "GCT/02/J/"
Private Sub Command1_Click( )
Dim stra, stre As String
Dim intb, intd As Integer
Dim strd As String
stra = "200"
intb = Val(stra) + 1
intd = Len(CStr(intb))
stre = String(4 - intd, "0") & CStr(intb)
MsgBox strC & stre
End Sub

now the issue is that based on last claim no. when the forms load, we
wants to generate a new no and insert table/add as new record. say we
have serial

GCT/02/J/001,GCT/02/J/002,GCT/02/J/003...SO ON so the new ID will be
GCT/02/J/004
so can any one put highlights how to do this...

regards,
shahzad

I use this to generate the numbers for one of my control logs
since it is a string value you can modify it easily to store the
"GCT/02/J/"

These two functions are in a module Named SerialNumber

Public Function nextNumber() As String
Dim nextSerial As Long
nextSerial = DMax("[CtrlNumber]", "tblSource" ) + 1
nextNumber = nextSerial
End Function

Public Function nextLogNbr() As String
nextLogNbr = nextNumber() & "-" & Right(Year(Date ), 2)
End Function

The data entry form for tblSource onLoad event is
DoCmd.GoToRecor d , , acNewRec

The data entry form for tblSource uses Three text boxes to record the
log number data, all have auto tab and tab stop set to no

a text box with the
control source = CtrlNumber
default value =nextNumber()
visable no

The LogNumber Text box
Control source = MstrLogNum
Default Value = nextLogNbr()
visable no

An unbound Text box
Control source
Default Value = nextLogNbr()
visable yes
Background color same as the form background
style flat

this allows the user to see the number (it looks like a lable but
should they click on it and type any data into it it has no effect on
the table.
Have a nice day. ld****@NOPANTS. juno.com

Remove NOPANTS. To reply by direct E-Mail;
Support: The Right to Privacy and Anti-SPAM projects
Nov 13 '05 #3

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

Similar topics

6
3806
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 taken from the part name (BrandA 300 4 Bladed : B3004B). The production number is a 4 or 5 digits number with first figure(s) indicating category...
6
5054
by: Alpha | last post by:
I retrieve a table with only 2 columns. One is a auto-generated primary key column and the 2nd is a string. When I add a new row to the dataset to be updated back to the database. What should I do with the 1st column ? (Below I have a "1" in place for now). Also, Does the datase.AcceptChanges(); updates the changes to the database? Which...
8
5800
by: Bill Rust | last post by:
I've created an "Add Item" wizard for VB.NET 2003 that allows a user to add a specialized class that works with my application framework. In the wizard, the user can select the interfaces they would like to support. During the code generation phase, I add an "Implements Ixxx" for each interface they select, but I've not yet figured out how...
6
3485
by: | last post by:
Hi, can someone provide some advise on how to get around with using auto generated proxies? basically I already have the proxy classes, and they are used by other places. I'd like use these existing classes instead of having to generate another set of proxy classes, which are going to be very similar to my existing classes. any idea? ...
13
4728
by: S.Dickson | last post by:
I had an access database that i use as an ordering system. I have a form for entering customer details. When i add a new customer on the form the customer number is an auto number that appears when i type in the details. I have just moved over to mysql server with access as the front end. I have setup the sql tables with the customer number...
2
5813
by: G | last post by:
Hello Firends I want a sample code for developing an " auto genearte number " and want to store in database. Please if you find any code please send Thanks in Advance G
1
1976
by: Maninder Karir | last post by:
Hi Im stuck AGAIN!!!!!! Sure its something simple but, Ive put together a code to generate an automatic number everytime i open the work book, However I now would rather only generate the number when I click on a particular button. The code works fine when its in a Private Sub Auto Open(). ive copied the code directly into a command...
1
2128
by: ganesh22 | last post by:
hi... I am doing a project asp.net with C#.my requirement I want to do auto generate password for my application that means when user forget his password when he clicks a link it will auto generate a new password and then it will send to a secondary mail
1
1276
by: PerumalSamy | last post by:
HI I done a project in asp.net with VB coding and sql server 2005 as back end. Now i need to generate an auto email everyday for current date based on the date field in my database table . For Example: Today is 05/03/2008 means, i want to generate a report(records from database related to this date) without logging into the software and...
0
7526
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...
0
7455
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7723
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. ...
0
7814
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...
0
6050
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...
1
5373
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5092
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3486
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1063
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.