CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Add the number 1 to number with .i in it

Print topic Send  topic

Author Message
deagon

Posts: 31
Posted: 07/03/2008, 12:02 PM

My code takes the last PO number and adds a one to it. No problem however when using
a number plus a letter at the end it gives a error because the system will not add a number unless it's just a number without characters. Does anyone know how I could sort or filter in order to add one for next PO in my system even with a .i or .r at the end. Like 2467.i the code is below.

If Right(Jobstorage20.JobNumAdd1.Value,2) <> ".1" AND Right(Jobstorage20.JobNumAdd1.Value,2) <> ".i" AND Right(Jobstorage20.JobNumAdd1.Value,2) <> ".r" Then
If Jobstorage20.Submit1.Value = True Then
Jobstorage20.JobNumAdd1.Value = Jobstorage20.JobNumAdd1.Value & ".1"
Elseif Jobstorage20.inspection1.Value = True Then
Jobstorage20.JobNumAdd1.Value = Jobstorage20.JobNumAdd1.Value & ".i"
Elseif Jobstorage20.repair1.Value = True Then
Jobstorage20.JobNumAdd1.Value = Jobstorage20.JobNumAdd1.Value & ".r"

End If
End If

Dim Conn
Set Conn = new clsDBJobstatus
Conn.open
If Jobstorage20.JobNumAdd1.Value <> "" Then
Jobstorage20.JobNumAdd1.Value = Jobstorage20.JobNumAdd1.Value
Else Jobstorage20.JobNumAdd1.Value = CCDLookup("Max(Jobnum)","Jobstorage","",Conn) + 1
'CCDLookup("Max(Jobnum)","Jobstorage","",Conn) + 1
End if


Thanks for your help!!
View profile  Send private message
Trigger
Posted: 07/07/2008, 6:29 PM

If you are using a database backend, I would suggest letting the database
generate the
next number for you.

In MS Access, there are autonumber fields. In databases like MSSQL Server,
you can
use an identity column.

The reason I say this is because if two users connect to your site at the
same time, they would
normally get the MAX(PO) number and add 1. Both orders would then have the
same PO number(not good).

If you let the database get the next PO number for you, it will
automatically increment for you and each user
would get a different PO number. No conflicts.


"deagon" <deagon@forum.codecharge> wrote in message
news:6486d2249d6820@news.codecharge.com...
> My code takes the last PO number and adds a one to it. No problem however
> when
> using
> a number plus letter at the end it gives a error because the system with
> not
> add a number unless it's just a number without characters. Does anyone
> know how
> I could sort or filter in order to add one for next PO in my system even
> with a
> i or .r at the end. Like 2467.i the code is below.
>
> If Right(Jobstorage20.JobNumAdd1.Value,2) <> ".1" AND
> Right(Jobstorage20.JobNumAdd1.Value,2) <> ".i" AND
> Right(Jobstorage20.JobNumAdd1.Value,2) <> ".r" Then
> If Jobstorage20.Submit1.Value = True Then
> Jobstorage20.JobNumAdd1.Value = Jobstorage20.JobNumAdd1.Value &
> ".1"
> Elseif Jobstorage20.inspection1.Value = True Then
> Jobstorage20.JobNumAdd1.Value = Jobstorage20.JobNumAdd1.Value &
> ".i"
> Elseif Jobstorage20.repair1.Value = True Then
> Jobstorage20.JobNumAdd1.Value = Jobstorage20.JobNumAdd1.Value &
> ".r"
>
> End If
> End If
>
> Dim Conn
> Set Conn = new clsDBJobstatus
> Conn.open
> If Jobstorage20.JobNumAdd1.Value <> "" Then
> Jobstorage20.JobNumAdd1.Value = Jobstorage20.JobNumAdd1.Value
> Else Jobstorage20.JobNumAdd1.Value =
> CCDLookup("Max(Jobnum)","Jobstorage","",Conn) + 1
> 'CCDLookup("Max(Jobnum)","Jobstorage","",Conn) + 1
> End if
>
>
> Thanks for your help!!
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

bburnett

Posts: 22
Posted: 07/09/2008, 12:30 PM

You could store the number and the .i / .r in separate fields and only show them together for the end user. (faster sql processing; easy to sort by the number field)
Or
in T-SQL you could sort using: order by cast(left(yourfield,len(yourfield)-2) as Integer)

If you've determined which PO is the highest you could use ASP To get the next number:
cint(left(yourvariable,len(yourvariable)-2))+1


_________________
Brandon Burnett
New Media Architect
REL Productions
West Des Moines, IA, USA
www.relonline.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.