G
gator
I am using Form1 to enter records. Some of the records use different Receipt
numbers and some use the same Receipt numbers. When the user clicks a button
to enter a record into the Table1 with the values that are in textboxes on
Form1, I want to set a condition that says - if the previous record's Name
field (text value) in Table1 has the same text/value as the text/value of the
Name field on Form1....then use the previous record's text/value in the
Receipt field, otherwise, add (increment) 1 to the value of that Receipt
number. Below is the code I am currently using on the click event.
Private Sub cmdEnterRecord_Click()
Dim mycon As New ADODB.Connection
Dim ADOrs As New ADODB.Recordset
Set mycon = CurrentProject.Connection
ADOrs.Open "Deposits", mycon, adOpenKeyset, adLockOptimistic
ADOrs.AddNew
ADOrs!Source = Me.txtSource
ADOrs!Type = Me.txtType
ADOrs!FundID = Me.txtFundID
ADOrs!Account = Me.txtAccount
ADOrs!Date = Me.txtDate
ADOrs!ID = Nz(DMax("[ID]", "Deposits"), 0) + 1
ADOrs.Update
ADOrs.Close
mycon.Close
Me.TreasurerDeposits.Requery
End Sub
numbers and some use the same Receipt numbers. When the user clicks a button
to enter a record into the Table1 with the values that are in textboxes on
Form1, I want to set a condition that says - if the previous record's Name
field (text value) in Table1 has the same text/value as the text/value of the
Name field on Form1....then use the previous record's text/value in the
Receipt field, otherwise, add (increment) 1 to the value of that Receipt
number. Below is the code I am currently using on the click event.
Private Sub cmdEnterRecord_Click()
Dim mycon As New ADODB.Connection
Dim ADOrs As New ADODB.Recordset
Set mycon = CurrentProject.Connection
ADOrs.Open "Deposits", mycon, adOpenKeyset, adLockOptimistic
ADOrs.AddNew
ADOrs!Source = Me.txtSource
ADOrs!Type = Me.txtType
ADOrs!FundID = Me.txtFundID
ADOrs!Account = Me.txtAccount
ADOrs!Date = Me.txtDate
ADOrs!ID = Nz(DMax("[ID]", "Deposits"), 0) + 1
ADOrs.Update
ADOrs.Close
mycon.Close
Me.TreasurerDeposits.Requery
End Sub