R
Rino
Greetings,
I am having problem with the following codes for some reason and I
cannot figure it out where the problem is. However, what I'm trying to
achive is to have a auto number generator for my quote form, so
basically this generator would create a quote number that will change
as new records are added. I am doing this in MS Access 2000.
here is the code:
-----------------------------------------------
Private Sub Form_BeforeInsert(Cancel As Integer)
Dim rst As DAO.Recordset
Dim i As Integer
Dim nMaxVal As Integer
Dim n As Integer
nMaxVal = 1630
Set rst = Me.RecordsetClone
If Not rst.BOF Then
rst.MoveFirst
End If
Do While Not rst.EOF
n = rst![Quote_Num]
If n > nMaxVal Then
nMaxVal = n
End If
rst.MoveNext
Loop
Me![Quote_Num] = nMaxVal + 1
End Sub
-----------------------------------------------------
My guess is that problem lays in the next one
------------------------------------------------------
Private Sub txtQuoteNo_Change()
Dim rst As DAO.Recordset, intI As Integer
Set rst = Me.RecordsetClone
If IsNull(rst![Quote_Num]) Then
intI = rst![Quote_Num]
Me![Quote_Num] = intI + 2
End If
End Sub
------------------------------------------------------
Could you please help me figure this out.
Thanks in advance
-Rino
I am having problem with the following codes for some reason and I
cannot figure it out where the problem is. However, what I'm trying to
achive is to have a auto number generator for my quote form, so
basically this generator would create a quote number that will change
as new records are added. I am doing this in MS Access 2000.
here is the code:
-----------------------------------------------
Private Sub Form_BeforeInsert(Cancel As Integer)
Dim rst As DAO.Recordset
Dim i As Integer
Dim nMaxVal As Integer
Dim n As Integer
nMaxVal = 1630
Set rst = Me.RecordsetClone
If Not rst.BOF Then
rst.MoveFirst
End If
Do While Not rst.EOF
n = rst![Quote_Num]
If n > nMaxVal Then
nMaxVal = n
End If
rst.MoveNext
Loop
Me![Quote_Num] = nMaxVal + 1
End Sub
-----------------------------------------------------
My guess is that problem lays in the next one
------------------------------------------------------
Private Sub txtQuoteNo_Change()
Dim rst As DAO.Recordset, intI As Integer
Set rst = Me.RecordsetClone
If IsNull(rst![Quote_Num]) Then
intI = rst![Quote_Num]
Me![Quote_Num] = intI + 2
End If
End Sub
------------------------------------------------------
Could you please help me figure this out.
Thanks in advance
-Rino