Solved

Syntax error - Insert records

Posted on 2016-08-23
2
27 Views
Last Modified: 2016-08-23
Experts, I keep getting a syntax on the insert line.  Do you see where I have made a mistake?  It might be something to do with the # placement on the date field.  the VBA is on a button on the parent and the records I am inserting are on a subform.

Private Sub cmdInsertRecords_Click()
   
    Dim db As DAO.Database, intMyValue As Date, intMyValue2 As Integer
    intMyValue = Me.DrawDate
    intMyValue2 = Me.Currency
   
    Set db = CurrentDb
    db.Execute "Insert into tblDraws_Details1 (ValueDate, Currency) VALUES (#" & intMyValue & "#," & intMyValue2 & ")"
   
    Set db = Nothing

End sub
0
Comment
Question by:pdvsa
[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 29

Accepted Solution

by:
IrogSinta earned 500 total points
ID: 41767465
You cannot use Currency as a field name in your table.  That is a reserved word.

Ron
0
 

Author Closing Comment

by:pdvsa
ID: 41767477
Oh i think I have been told that before.  Completely slipped my mind. Thank you
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
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, when working with VBA, learn some techniques for writing readable and easily maintained code.

636 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