Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8443041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:01:14+00:00 2026-06-10T09:01:14+00:00

I need help figuring out an error in my SQL statement. I have been

  • 0

I need help figuring out an error in my SQL statement. I have been trying several things, but nothing seems to work?
This is the error message I receive

Run-time error '3075':

Syntax error (missing operator) in query expression '([description] = Manufacturing and Delivery Schedule AND [pr_num] = 83)'.

This is my code:

Private Sub Command6_Click()
' ===================================================
' Receives the selected item in the combo box
' ===================================================

' Open the Database connection
Dim data_base As Database
Set data_base = CurrentDb

' Grab description and pr number from the form
Dim desc As string
dim pr_number as long
desc = Combo4.Value
pr_number = Text8.Value

' Build the query
Dim query As String
query = "UPDATE VDR_Table " & _
    "SET [received] = [p1] " & _
    "WHERE ([description] = " & desc & _
    " AND [pr_num] = " & pr_number & ");"

Dim rec_set As DAO.Recordset
Set rec_set = data_base.OpenRecordset(query)

' Build the QueryDef
Set qd = data_base.CreateQueryDef("")
qd.SQL = query

' Execute query
qd.Parameters("p1").Value = true
qd.Execute

' Close nad null record set
rec_set.close
set rec_set = nothing

' Close the connection to the database
data_base.Close

' Prompt the user success
MsgBox "Item has been received"
End Sub

Thanks in advance for any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:01:16+00:00Added an answer on June 10, 2026 at 9:01 am

    You need to enclose the description field value you are setting in quotes since it is a string field. It should look like this:

    ' Build the query
    Dim query As String
    query = "UPDATE VDR_Table " & _
        "SET [received] = [p1] " & _
        "WHERE ([description] = '" & desc & _
        "' AND [pr_num] = " & pr_number & ");"
    

    Removed the links below since they don’t matter in this case.

    Also, I would recommend using parameters instead of string concatenations to avoid SQL injections. Here’s an example of using parameters with VBA – http://support.microsoft.com/kb/181734 – and here is some reasoning on why to use parameterized sql – http://www.codinghorror.com/blog/2005/04/give-me-parameterized-sql-or-give-me-death.html.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help figuring out and SQL Statement. I know what I want
I know I'm close to figuring this out but need a little help. What
Need help figuring this out. I have two tables user ---- name skills (comma
Need help figuring this out. Have a product model: class Product :name :short_description :price
I need help in figuring out the solution for my problem. 1. I have
I'm doing an ASP.Net MVC website, but I need some help figuring out how
I have weird problem with django translations that i need help figuring out. Problem
I need help figuring out why my rspec tests are running slowly. I am
I need some help figuring out how I should do this. I would like
I need a little help figuring out what the following URL rewrite rule means.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.