?
Solved

INSERT INTO statement not working - ACCESS 2010 database

Posted on 2013-12-12
2
Medium Priority
?
470 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
gozoliet earned 2000 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

764 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