Solved

INSERT INTO statement not working - ACCESS 2010 database

Posted on 2013-12-12
2
457 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
Many companies are making the switch from Microsoft to Google Apps (https://www.google.com/work/apps/business/). Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now