ClaraBarton
Registered User.
- Local time
- Today, 11:48
- Joined
- Oct 14, 2019
- Messages
- 578
I have a continuous form that's a check register and the query behind it is not updatable.
Double clicking in any field transfers the record fields to unbound fields in the header.
I have saving a new record working but I'm a little lost on updating an existing record.
How do I make sure the update goes back to the same record?
In other words, if the ID is null a new record is created in the table.
The second part (else) is what doesn't work:
Double clicking in any field transfers the record fields to unbound fields in the header.
I have saving a new record working but I'm a little lost on updating an existing record.
How do I make sure the update goes back to the same record?
In other words, if the ID is null a new record is created in the table.
The second part (else) is what doesn't work:
Code:
Private Sub btnSave_Click()
Dim rst As DAO.Recordset
Dim strSql As String
strSql = "Select * from tblTransactions " & _
"WHERE TransactionID = " & Nz(Me.txtTransactionID, 0)
Set rst = CurrentDb.OpenRecordset(strSql)
If IsNull(Me.txtTransactionID) Then
With rst
.AddNew
fAccountID = Me.txtfAccountID
TransactionID = Me.txtTransactionID
CkDate = Me.txtDate
Num = Me.txtNum
Payee = Me.txtPayee
Debit = Me.txtDebit
Credit = Me.txtCredit
Cleared = Me.txtCleared
.Update
End With
Else
With rst
.Update 'update or cancel without add new or edit
fAccountID = Me.txtfAccountID
TransactionID = Me.txtTransactionID
CkDate = Me.txtDate
Num = Me.txtNum
Payee = Me.txtPayee
Debit = Me.txtDebit
Credit = Me.txtCredit
Cleared = Me.txtCleared
End With
End If
Set rst = Nothing
End Sub