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