PDA

View Full Version : ERROR IN CODING



Expand
10-14-2008, 11:50 PM
Hi,
Can someone tell me what is the problem in the below coding. In fact, i have a table called parametres with fields, Famille, Libelle, Code, numerique and another table called, STATION_CR_POS with fields strstationPCISacc, NUM_STATION_CR_POS. In the table parametres, the field numerique must be incremented which is not working. The code is :
Function Num?ro_STATIONCRPOS() As Integer
Dim BdD As Database
Dim F, P As Recordset
Dim D, T As String
Dim C, Z, N As Integer

On Error Resume Next

Screen.MousePointer = 11

Set BdD = CurrentDb
Set F = BdD.OpenRecordset("Select * From STATION_CR_POS Order By idstation", dbOpenDynaset)
Set P = BdD.OpenRecordset("Parametres", dbOpenTable)
P.Index = "Famille_Libelle"

P.Seek "=", "Facture", "NUM_STATION_CR_POS"
Select Case P.NoMatch
Case False
D = P("Code")
N = P("Numerique")
Case True
MsgBox "Num?ro de Facture Non Trouv?..." & Chr(10) & "Abandon de la Proc?dure", vbCritical + vbOKOnly, "Fichier Param?tres hebdo"
Exit Function
End Select

C = 0

F.MoveFirst
Do While F.EOF = False
Select Case F("strstationPCISacc")
Case C
Case Else
N = N + 1
Select Case N
Case Is < 1000000
Case Else
D = Chr(Asc(D) + 1)
N = 1
End Select
C = F("strstationPCISacc")
End Select
F.Edit
T = Format(N, "00000000")
F("NUM_STATION_CR_POS") = T
' F("DatFact") = Now
F.Update
F.MoveNext
Loop

F.Close

P.Edit
'P("Code") = D
P("Numerique") = N
P.Update
P.Close

Screen.MousePointer = 0

Num?ro_STATIONCRPOS = True

End Function

Thanks to help.
Regards,
Shaheen.