Ver Mensaje Individual
  #4 (permalink)  
Antiguo 11/12/2006, 06:57
Avatar de tazzito
tazzito
 
Fecha de Ingreso: agosto-2006
Mensajes: 381
Antigüedad: 18 años, 8 meses
Puntos: 2
Re: Generador de codigos

Public Function Generar_Id_Llamada() As String
On Error GoTo MiError
LLamadaDAO
Set rs = New ADODB.Recordset
With rs
.ActiveConnection = cn
.Source = "SELECT TOP 1 Id_Llamada FROM LLamada ORDER BY Id_Llamada Desc"
.CursorLocation = adUseClient
.Open
End With

If TypeName(rs) = "Recordset" And Not rs.EOF Then
ultimo = rs(0)
Else
ultimo = 0
End If

Generar_Id_Llamada = "T" & Right("0000000" & trim(ultimo + 1), 6)

Set rs = Nothing
Exit Function
MiError:
MsgBox Err.Description, vbCritical, "Error"
End Function