Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 22nd, 2004, 03:18 PM
Authorized User
 
Join Date: Jun 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Syntax Error

HELP! I'm trying to figure this out. This is what I'm trying to do. I have a group of tables with the same specs. I want to programmatically append the information in these tables into a master table, aptly named, master table.

Here's the Code. I get a syntax error and i don't know why. :(
Your help would be greatly appreciated.

Public Function AppendFile()
'The AppendFile function appends individual company tables to the Master Table, tblMaster.
    Dim qryAppend As QueryDef
    Dim rstAppend As Recordset
    Dim db As Database
    Set db = CurrentDb()
    Set rstAppend = db.OpenRecordset("tblFilePath")

    rstAppend.MoveFirst

    Do Until rstAppend.EOF()
        DoCmd.DeleteObject acQuery, "AppendImports"
        Set qryAppend = CurrentDb.CreateQueryDef("AppendImports")
        qryAppend.SQL = "INSERT INTO tblMASTER ( Company_Number, Location_Code, Customer_Number, Customer_Name," & _
        "Address, ZipCode, Geocode, State, County, City, Gross_Sales, Gross_RX_Sales, Gross_OTC_Sales, Gross_Lease_Sales," & _
        "Exempt_Sales, Exemption_Code, Taxable_Sales, Taxable_RX_Sales, Taxable_OTC_Sales, Taxable_Lease_Sales, " & _
        "Taxable_Purchases, Sales_Tax, RX_Tax, OTC_Tax, Sellers_Use, Consumers_Use, Rental_Tax, Tax_Rate, " & _
        "Period_Begin_Date, Period_End_Date)"
        "SELECT " & rstAppend.Fields(3).Value & ".Company_Number, " & rstAppend.Fields(3).Value & ".Location_Code," & rstAppend.Fields(3).Value & _
        ".Customer_Number," & rstAppend.Fields(3).Value & ".Customer_Name," & rstAppend.Fields(3).Value & ".Address," _
        & rstAppend.Fields(3).Value & ".ZipCode," & rstAppend.Fields(3).Value & ".GeoCode," & rstAppend.Fields(3).Value _
        & ".State," & rstAppend.Fields(3).Value & ".County," & rstAppend.Fields(3).Value & ".City," & rstAppend.Fields(3).Value _
        & ".Gross_Sales," & rstAppend.Fields(3).Value & ".Gross_RX_Sales," & rstAppend.Fields(3).Value & ".Gross_OTC_Sales," _
        & rstAppend.Fields(3).Value & ".Gross_Lease_Sales," & rstAppend.Fields(3).Value & ".Exempt_Sales," _
        & rstAppend.Fields(3).Value & ".Exemption_Code," & rstAppend.Fields(3).Value & ".Taxable_Sales," & rstAppend.Fields(3).Value _
        & ".Taxable_RX_Sales," & rstAppend.Fields(3).Value & ".Taxable_OTC_Sales," & rstAppend.Fields(3).Value & ".Taxable_Lease_Sales," _
        & rstAppend.Fields(3).Value & ".Taxable_Purchases," & rstAppend.Fields(3).Value & ".Sales_Tax," & rstAppend.Fields(3).Value & ".RX_Tax," _
        & rstAppend.Fields(3).Value & ".OTC_Tax," & rstAppend.Fields(3).Value & ".Sellers_Use," & rstAppend.Fields(3).Value & ".Consumers_Use," _
        & rstAppend.Fields(3).Value & ".Rental_Tax," & rstAppend.Fields(3).Value & ".Tax_Rate," & rstAppend.Fields(3).Value & ".Period_Begin_Date," _
        & rstAppend.Fields(3).Value & ".Period_End_Date FROM " & rstAppend.Fields(3).Value & ";"

        DoCmd.OpenQuery "AppendImports", acViewNormal

        rstAppend.MoveNext
        qryAppend.Close
    Loop

End Function

 
Old June 22nd, 2004, 03:21 PM
Authorized User
 
Join Date: Jun 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

one more thing...i'm using access 97.

 
Old June 22nd, 2004, 04:50 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

At:

 "Period_Begin_Date, Period_End_Date)"
 "SELECT " & rstAppend.Fields(3).Value & ".Company_Number, " & rstAppend.Fields(3).Value & ".Location_Code," & rstAppend.Fields(3).Value & _

Remove the double quote after Date)" and before "SELECT.

The SELECT clause is part of your INSERT INTO statement.

Bob




 
Old June 23rd, 2004, 08:26 AM
Authorized User
 
Join Date: Jun 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks so much! :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: syntax error, unexpected T_ELSE in /h vipin k varghese BOOK: XSLT Programmer's Reference, 2nd Edition 4 September 29th, 2011 01:19 AM
Ch 4: Parse error: syntax error, unexpected T_SL hanizar77 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 23rd, 2008 09:17 PM
Parse error: syntax error, unexpected T_STRING ginost7 Beginning PHP 1 November 9th, 2007 02:51 AM
VB Error: Syntax Error or Access Violation codehappy VB How-To 7 October 3rd, 2007 05:41 PM
Compile error: Syntax error: & Else without HELP Corey VB How-To 2 April 21st, 2006 03:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.