Solved current db execute - update table error 3078 (1 Viewer)

Ihk

Member
Local time
Today, 07:04
Joined
Apr 7, 2020
Messages
238
1) I have a form with listbox (query sourced), results are filtered on search.
2) Click on any record in lisbox, populates form data, on ID (ID_ArticleDetails) match basis.
3) form has two comboboxes, which are autopopulated as of point 2.
4) these comboboxes have bound column of ID, while user can see text.
5) user can select data from these comboboxes to change the record. Basically IDs (foriegn IDs) will be updated.

If too complex, ignore above,
What I want,-- on click button
I want to update another two other fields in table based on ID_ArticleDetails on the form as well as in table being updated
button has following code, and gives me error 3048
I feel that there are some comma, conjuntion errors. I could not figure out.
Code:
Private Sub btnUpdate_Click()
Dim DetailsID As Integer
DetailsID = Me.ID_ArticleDetails
CurrentDb.Execute "UPDATE MainOrdersEntries SET ID_Article = Me.ID_Article" & ID_Company = Me.ID_Company & _
           " WHERE ID_ArticleDetails = DetailsID"
End Sub
 

cheekybuddha

AWF VIP
Local time
Today, 06:04
Joined
Jul 21, 2014
Messages
1,102
Going solely on the SQL and not considering whether what you are attempting is a valid operation, try:
Code:
Private Sub btnUpdate_Click()

  Dim DetailsID As Integer, strSQL As String
 
  DetailsID = Me.ID_ArticleDetails
  strSQL = "UPDATE MainOrdersEntries SET ID_Article = " & Me.ID_Article & ", ID_Company = " & Me.ID_Company & _
           " WHERE ID_ArticleDetails = " & DetailsID
  Debug.Print strSQL   ' Check output value in Immediate Window (Ctrl+G)
  CurrentDb.Execute strSQL, dbFailOnError
 
End Sub
 
  • Love
Reactions: Ihk

Gasman

Enthusiastic Amateur
Local time
Today, 06:04
Joined
Sep 21, 2011
Messages
10,881
Why not put it all into a string variable and then debug.print it to see the error? :(
 

Ihk

Member
Local time
Today, 07:04
Joined
Apr 7, 2020
Messages
238
Going solely on the SQL and not considering whether what you are attempting is a valid operation, try:
Code:
Private Sub btnUpdate_Click()

  Dim DetailsID As Integer, strSQL As String

  DetailsID = Me.ID_ArticleDetails
  strSQL = "UPDATE MainOrdersEntries SET ID_Article = " & Me.ID_Article & ", ID_Company = " & Me.ID_Company & _
           " WHERE ID_ArticleDetails = " & DetailsID
  Debug.Print strSQL   ' Check output value in Immediate Window (Ctrl+G)
  CurrentDb.Execute strSQL, dbFailOnError

End Sub
Thank you very much. Problem solved.
 

Users who are viewing this thread

Top Bottom