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 7928231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:40:57+00:00 2026-06-03T19:40:57+00:00

This is pretty easy question, but I have been unable to find the solution

  • 0

This is pretty easy question, but I have been unable to find the solution using google. More than likely I am using the wrong terminology. Any help in addressing my issue or pointing me in the right direction would be greatly appreciated. Due an in house requirement at my company, I am creating an Access database with an ODBC connection to SQL Server to maintain a user defined table. It has been a while since I have programmed in VBA.

I am using an Access Form to pull up the data to be edited. With a button press, a query runs and brings back one row based on the criteria. I am using a record set to hold the information pulled back from the query. My goal is to then put the data from the query into text boxes where they can be edited, then do an update statement with the changes made. However, the code I wrote to put the record set data into the various text boxes is failing and I’m not able to figure out why.

Here is my code:

Dim rst As Recordset
    'add rows to record set
Set rst = CurrentDb.OpenRecordset("Select Parent_Name, Child_Name, Address, City, State, Zip, CustomerID, Facility, SystemID, " & _
            "from Table where CustomerID = '" & Forms!Frm_Edit_Child!cbx_Cust_ID & "' and  Facility = '" & Forms!Frm_Edit_Child!cbx_Facility & "' and SystemID = '" & _
            Forms!Frm_Edit_Child!cmb_SystemID & "';")

rst.MoveLast

Me.txt_Edit_IDN_Name.Text = rst.Fields("Parent_Name").Value
Me.txt_Edit_Customer_ID.Text = rst.Fields("CustomerID").Value
Me.txt_Edit_Facility.Text = rst.Fields("Child_Name").Value
Me.txt_Edit_Facility_Num.Text = rst.Fields("Facility").Value
Me.txt_Edit_Address.Text = rst.Fields("Address").Value
Me.txt_Edit_City.Text = rst.Fields("City").Value
Me.cmb_Edit_State.Text = rst.Fields("State").Value
Me.txt_Edit_Zip.Text = rst.Fields("Zip").Value
Me.cmb_Edit_SystemID.Text = rst.Fields("SystemID").Value

I think the way I am attempting to reference the data in the record set is wrong, but I’m not able to figure out where I went wrong or use the proper terminology to find a solution via Google. Thank you for your time!

  • 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-03T19:40:58+00:00Added an answer on June 3, 2026 at 7:40 pm

    I think you have multiple issues with that code. Before discussing them I will offer you this advice. Telling us your code fails is nowhere near as useful as telling us “CurrentDb.OpenRecordset triggers error #3141, ‘The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.'”

    Discard the comma after SystemID in your SELECT statement field list. The last field expression can’t be followed by a comma or you will trigger error #3141.

    Store your SELECT statement in a string variable, then Debug.Print it before you use it to open the recordset.

    Dim strSelect As String
    strSelect = "Select Parent_Name, Child_Name, Address, City, " & _
        "State, Zip, CustomerID, Facility, SystemID " & _
        "from [Table] where CustomerID = '" & _
        Forms!Frm_Edit_Child!cbx_Cust_ID & "' and  Facility = '" & _
        Forms!Frm_Edit_Child!cbx_Facility & "' and SystemID = '" & _
        Forms!Frm_Edit_Child!cmb_SystemID & "';"
    Debug.Print strSelect
    Set rst = CurrentDb.OpenRecordset(strSelect)
    

    Then if you still encounter an error on CurrentDb.OpenRecordset, you can go to the Immediate window (CTRL+g) to view the statement you’re asking the db engine to use. You may spot the problem as soon as you see the actual completed statement. If not, you can copy the statement and paste it into SQL View of a new query … figure out what changes are needed to avoid the error, then revise your VBA code so that it produces the same correct SQL statement. If that still doesn’t fix you up, paste the SQL into your question and tell us what error message you get from that SQL.

    Table is a reserved word. See Problem names and reserved words in Access. If you must keep that as the table name, enclose it in square brackets to avoid confusing Access’ db engine.

    There could be a problem with this next line if your application includes a reference for Microsoft ActiveX Data Objects and it has a higher precedence than DAO.

    Dim rst As Recordset
    

    It’s safer to explicitly declare the type of recordset you want.

    Dim rst As DAO.Recordset
    

    Drop .Text from lines like these as @user247245 suggested. The .Text property is only available for the control which currently has focus.

    Me.txt_Edit_IDN_Name.Text
    

    You want .Value instead. You can add it, but you don’t need to because .Value is the default property. So these 2 are functionally equivalent:

    Me.txt_Edit_IDN_Name.Value
    Me.txt_Edit_IDN_Name
    

    Finally, I think this situation would be much simpler with a form bound to the SELECT statement. You wouldn’t have to fill your text box values because Access will do that for you automagically with bound controls. You could revise the form’s Record Source based on cbx_Cust_ID, cbx_Facility, and cmb_SystemID in the after update events of those controls or from the click event of a command button. If the code you showed us is from a different form (not Frm_Edit_Child), you would have to use the command button approach.

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

Sidebar

Related Questions

This sounds like a pretty easy question to answer but I haven't been able
Pretty sure there is an easy answer to this, but just can't find the
I have a pretty easy question. (using C) In a sentence such as In
So this is a pretty general question, but I've been wondering about it for
OK, I know this question seems pretty easy to answer, or maybe documented, but
I think this is a pretty easy question...How do I make a asp.net function
this is prob pretty easy but if someone could explain the easiest way to
I thought this would be pretty easy but I'm running into all sorts of
I have a feeling that this query is pretty easy to construct, I just
I'm using sqlite3 and this would be pretty easy if it supported TOP syntax

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.