Share via

Run-time Error 3075 when executing an SQL UPDATE

Anonymous
2020-04-28T16:46:06+00:00

Hello guys! I hope you can help me with my concern. So I am trying run the below code to update previously encoded records in the table "lib_gSupp". Under the said table, it has 5 fields namely: (a) gSupp_ID, (b) gName_ID, (c) Supplemental_Information, (d) Entry_Date, and (e) Date_Modified.

But for the code that I am trying to run, I only need to update 2 fields: (a) Supplemental_Information and (b) Date_Modified.

Below is my code for this but unfortunately I am stuck with an error and the message is this:

"Run-time error '3075': Syntax Error (Missing Operator) in query expression (Me.txt_ed_gSupp).

    Dim dbs As DAO.Database, sql As String, rCount As Integer

    Set dbs = CurrentDb

    sql = "UPDATE lib_gSupp SET Supplemental_Information=" & Me.txt_ed_gSupp _

        & ",Date_Modified=" & Now() & " WHERE gSupp_ID=" & Me.txt_ed_gSuppID

    dbs.Execute sql, dbFailOnError

    rCount = dbs.RecordsAffected

    If rCount > 0 Then

        MsgBox "Supplemental Information Updated!", , "Update Success"

        Me.cmb_ed_gSupp.Requery

        Me.cmb_ed_gName.Value = ""

        Me.cmb_ed_gSupp.Value = ""

        Me.txt_ed_gSupp.Value = ""

        Me.cmb_ed_gSupp.Visible = True

        Me.txt_ed_gSupp.Visible = False

        Me.cmd_Update.Caption = "Edit"

        Me.cmb_ed_gName.SetFocus

        Exit Sub

    End If

The control source of Me.txt_ed_gSuppID is based on the Column(0) of a combobox (cmb_ed_gSupp).

I hope you can help me with this. I have little to no background on programming and MS access. I tried searching the internet but I came with different situation. Thank you!

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2020-04-28T20:17:23+00:00

Assuming that Supplemental_Information is a text field, use

    sql = "UPDATE lib_gSupp SET Supplemental_Information='" & Me.txt_ed_gSupp _

        & "',Date_Modified=Now() WHERE gSupp_ID=" & Me.txt_ed_gSuppID

Was this answer helpful?

0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Anonymous
    2020-04-30T09:49:33+00:00

    Now I get it. Thanks HansV! Cheers!

    Was this answer helpful?

    0 comments No comments
  2. HansV 462.6K Reputation points
    2020-04-29T11:03:23+00:00

    Literal text values must be enclosed in either single quotes ' ' or double quotes " ". I used single quotes here, since  the sql string already uses double quotes.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2020-04-29T04:05:59+00:00

    Thanks HansV! It worked like a charm! If you don't mind, for future reference, can I know what does the single apostrophe mean on the string? And  why removing "&" and adding the single apostrophe solved it? Again, thank you so much! :D

    Was this answer helpful?

    0 comments No comments