Advertisement

04.20.2007 at 08:32AM PDT, ID: 22524115
[x]
Attachment Details

INSERT INTO sql query in VB

Asked by rasta2212 in Microsoft Access Database

Tags: insert, access, sql, vb, date

Hello experts.  I am trying to create a sub procedure in VBA that will take the value of a date field in one table and add that date to the date field in another table.  (Access 2003 database).  I keep getting an error that says "Syntax error in INSERT INTO statement" When I debug it takes me to the line in my code "cnCurrent.Execute strSQL".  Any ideas?  Here is the code in the sub:

Private Sub UpdateDate()
Dim cnCurrent As ADODB.Connection
Dim strSQL As String
Set cnCurrent = CurrentProject.Connection    
strSQL = "INSERT INTO tblDate ( Date ) " & _
    "SELECT tblTempDate.Date FROM tblTempDate " & _
    "GROUP BY tblTempDate.Date"    
cnCurrent.Execute strSQL
cnCurrent.Close
Set cnCurrent = Nothing
txtLastDate.Requery
End Sub

Thanks!
~rasta2212Start Free Trial
 
Loading Advertisement...
 
[+][-]04.20.2007 at 08:40AM PDT, ID: 18947264

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04.20.2007 at 08:41AM PDT, ID: 18947270

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Access Database
Tags: insert, access, sql, vb, date
Sign Up Now!
Solution Provided By: angelIII
Participating Experts: 3
Solution Grade: A
 
 
[+][-]04.20.2007 at 08:42AM PDT, ID: 18947277

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04.20.2007 at 08:45AM PDT, ID: 18947303

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.20.2007 at 08:51AM PDT, ID: 18947352

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32