Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: sql increment field


Message #1 by "=?ISO-8859-1?Q?Antulio=20Mu=F1oz?=" <MunozRa@l...> on Wed, 27 Nov 2002 09:23:10 -0700
Hi.
You can use a sub to get the last itemscounter fields and then 
increment it
by 1 (or by any other value). Something like:

Private Sub MaxID()
    '
    Dim qry_max As String
    '
   
    qry_max_ent =3D "select max(ItemsCounter) From table"
    'feed the query to your dynaset - here I use an oracle dynaset
	Set MaxDynaset =3D OraDatabase.CreateDynaset(qry_max_ent, &H0&)
   
    If MaxDynaset.RecordCount > 0 Then 'check to see the query returned
something
        txtbox.Text =3D Str(MaxDynaset.Fields(0).Value + 1) 'add 1 to 
the last
value found
    End If
    '
End Sub


Hope this helps.

M=E1rio Ramos
TI - Gestor de Projectos
Telf: 234 10 10 52
Email: Mario.Ramos@e...
WWW: www.weber-cimenfix.com


-----Mensagem original-----
De: Antulio Mu=F1oz [mailto:MunozRa@l...]
Enviada: quarta-feira, 27 de Novembro de 2002 16:23
Para: professional vb
Assunto: [pro_vb] sql increment field


I need help with that:

I have a table with a field called ItemsCounter.  I need fill the field
counter with a consecutive numeric value when I insert new values, like 
a
Autonumeric or identity atribute.

My query is
INSERT Table
Select ID,Number,desc, itemscounter
FROM Table2

I need itemcounter be a function or something that increase the value 
from 1
to n.

help me please.


------------------------------------------------------------------------
----
--
This message may contain confidential information, and is intended only 
for
the use of the individual(s) to whom it is addressed.


=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D
=3D=3D



  Return to Index