Feb 17 2022 06:08 PM
Hello experts, I am trying to add a where clause to the below (red text). It is my code so yes it is not correct. Do you see where I am wrong?
Dim strSQL As String
DoCmd.RunCommand acCmdSaveRecord
If Not IsNull(Me.cboCurrency) Then
strSQL = "INSERT INTO tblPmtProposal (IDBankAcctfk) VALUES (" & Me!cboCurrency.Column(1) & ")", "[ID]=" & Me.txtID
CurrentDb.Execute strSQL, dbFailOnError
Else
End If
Feb 17 2022 08:00 PM
Feb 18 2022 03:50 AM
Hi,
You should explain what you want to achieve, because a WHERE clause for the target table in an append query is not useful. What do you want to filter by the txtID expression?
Servus
Karl
************
Access News
Access DevCon
Feb 18 2022 03:56 AM
Hi Arnel,
thank you.
Yes, I am inserting only 1 field (IDBankAcctfk).
I am inserting Me!cboCurrency.Column(1)
but I need to insert WHERE "[ID]=" & Me.txtID
Right now, without the WHERE condition, its inserting a record in tblPMTProposal but its not according to the where condition.
I think I need to append that WHERE condition to that insert statement somehow.
I hope that it makes sense.
Maybe I am not following.
thank you
Feb 18 2022 03:58 AM
Feb 18 2022 04:00 AM
Feb 18 2022 04:12 AM - edited Feb 18 2022 04:14 AM
SolutionHi,
If I understand right then you are looking for:
strSQL = "UPDATE tblPmtProposal " & _
" SET IDBankAcctfk = " & Me!cboCurrency.Column(1) & _
" WHERE ID = " & Me!txtID
Servus
Karl
************
Access News
Access DevCon
Feb 18 2022 04:21 AM
Feb 18 2022 06:04 AM
Feb 18 2022 04:12 AM - edited Feb 18 2022 04:14 AM
SolutionHi,
If I understand right then you are looking for:
strSQL = "UPDATE tblPmtProposal " & _
" SET IDBankAcctfk = " & Me!cboCurrency.Column(1) & _
" WHERE ID = " & Me!txtID
Servus
Karl
************
Access News
Access DevCon