Using MS Access/Syntax error - ??

Advertisement


Question
Hi Scott,

I try running this modified code, and get a syntax error.   Can you run a fine toth comb over it and point out where the flaw is please?  It's very frustrating :)

For i = 1 To DateDiff("d", Me.StayDate, Me.DepartDate) - 1
   strSQL = "INSERT INTO TblBookingDates (StayDate, RmNumber, BookingID,) " & _
         "VALUES(#" & DateAdd("d", i, Me.StayDate) & "#, " & Me.RmNumber & ", " & Me.BookingID & ");"
   CurrentDb.Execute strSQL
Next i

The only fields in TblBookingDates are BookingID, RmNumber and StayDate, and it's supposed to add records for each booking date between two dates, starting with StayDate but not including DepartDate

Thanks in anticipation
Pete

Answer
Sorry, somehow this slipped my notice.

I don't see anything wrong with the code. What is the error you are getting?

Hope this helps,
Scott<>
Blog: http://scottgem.wordpress.com
Website: http://www.diamondassoc.com
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA

Using MS Access

All Answers


Answers by Expert:


Ask Experts

Volunteer


Scottgem

Expertise

I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience

I've been designing databases for over 25 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

Education/Credentials
Brooklyn College BA

©2016 About.com. All rights reserved.