1

I keep getting an "Enter Parameter Value" input box when I run this code.

Private Sub UpdateTables()
Dim strSQL As String
strSQL = "update tblTest,ImportedTable set tblTest.Unit_Cost=ImportedTable.Unit_Cost where tblTest.Part_No=ImportedTable.Part_No"
DoCmd.RunSQL strSQL
End Sub

The box shows up for tblTest.Unit_Cost, ImportedTable.Unit_Cost, tbltTest.Part_No, and ImportedTable.Part_No.

The two tables, tblTest and ImportedTable exist and are spelled properly. Unit_Cost and Part_No both have spaces in the field names (I know that's terrible) hence the '_' in referencing them. I tried taking the space out and rerunning the code, but that didn't fix it.

Any thoughts on what I'm doing incorrectly? Thanks!

1
  • 1
    use [] around field names with spaces - e.g. ImportedTable.[Unit Cost] Commented Apr 3, 2013 at 14:50

1 Answer 1

3

In MS Access you must enclose field names in brackets [] when the field contains spaces.

Private Sub UpdateTables()
Dim strSQL As String
strSQL = "update tblTest,ImportedTable set tblTest.[Unit Cost]=ImportedTable.[Unit Cost] where tblTest.[Part No]=ImportedTable.[Part No]"
DoCmd.RunSQL strSQL
End Sub
Sign up to request clarification or add additional context in comments.

1 Comment

You are quite welcome. Please mark this answer as accepted so that others know a solution has been provided.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.