Solved

INSERT INTO statement not working - ACCESS 2010 database

Posted on 2013-12-12
2
464 Views
Last Modified: 2013-12-12
I just do not know what is wrong with this statement.

    DoCmd.RunSQL "INSERT INTO tblIDNums(MachineUserID, MachineID) " & _
        "VALUES(" & fntVBUserName & ", " & fntMachineName() & " "
0
Comment
Question by:ssmith94015
2 Comments
 
LVL 4

Accepted Solution

by:
gozoliet earned 500 total points
ID: 39715315
Your string variables need to be contained within quotes and closing parenthesis missing:

DoCmd.RunSQL "INSERT INTO tblIDNums(MachineUserID, MachineID) " & _
        "VALUES('" & fntVBUserName & "', '" & fntMachineName() & "') "


Note I added a single quote before/after the variables. If you have single quotes in your variables you need to escape or you may run into problems.

Better solution is to use a querydef with parameters so that you don't have to worry about special characters in the string.
0
 

Author Closing Comment

by:ssmith94015
ID: 39715386
went the querydef route, was better.

Sandra
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This collection of functions covers all the normal rounding methods of just about any numeric value.
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question