Solved

INSERT INTO statement not working - ACCESS 2010 database

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

MS Access 2003 or later To MySQL Migration Project Hello All, this is my second article in the category of MS-OFFICE Automation. In internet I am not able to find any comprehensive resource on the Migration of MS Access back-end to MySQL so I fin…
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
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 coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

863 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

27 Experts available now in Live!

Get 1:1 Help Now