473,396 Members | 1,849 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help INSERT INTO Statement, Using VB in Access 2003 Module

Hi
I have code below that enables a user to browse for an excel file, import the spreadsheet data, and dump it into a table . I keep receiving 3134 syntax error for "INSERT INTO" statement. Could someone please help me out? Also when I copy and paste this code into a module in a new database, I get an error message for the "Dim dlgPickFiles As Office.FileDialog" statement. I didn't get this error message in the old database, and don't understand why the code for browsing for data runs in the old database and not in the new database?

Thanks


Expand|Select|Wrap|Line Numbers
  1. Private Sub btnImportData_Click()
  2.  
  3. Dim dlgPickFiles As Office.FileDialog
  4. Dim strFileName As String
  5.  
  6. Set dlgPickFiles = Application.FileDialog(msoFileDialogFilePicker)
  7.  
  8. With dlgPickFiles
  9.      .AllowMultiSelect = False
  10.      With .Filters
  11.         .Clear
  12.         .Add "Excel files", "*.xls"
  13.     End With
  14.       .Show
  15.       strFileName = .SelectedItems(1)
  16.       End With
  17.  
  18.     Set dlgPickFiles = Nothing
  19.  
  20.     With DoCmd
  21.         .TransferSpreadsheet acLink, acSpreadsheetTypeExcel9, _
  22.             "tblTempLink", strFileName, False, "Data Output!A2:C2"
  23.         .RunSQL "INSERT INTO [TBL Import_Excel] (Sponsor, Owner, Project_Name) " & _
  24.             "SELECT tblTempLink.Sponsor, tblTempLink.Owner, tblTempLink.Project_Name " & _
  25.             "FROM tblTempLink;"
  26.         .DeleteObject acTable, "tblTempLink"
  27.     End With
  28.  
  29. End Sub
Oct 1 '07 #1
3 2378
kadghar
1,295 Expert 1GB
Hi
(...) message for the "Dim dlgPickFiles As Office.FileDialog" statement. I didn't get this error message in the old database, and don't understand why the code for browsing for data runs in the old database and not in the new database?

Thanks
Some VBA versions dont allow you to declare some kind of objects, if you're not using the name, then just put the file dialog in the with:

With Application.FileDialog(msoFileDialogFilePicker)
.filters(...)
.selection(...)
end with

That'll do
Oct 1 '07 #2
What about the syntax error for the "INSERT INTO" statement?
Oct 2 '07 #3
Killer42
8,435 Expert 8TB
Is it possible you misspelled a field name? Or perhaps the import is not setting the field names correctly.
Oct 3 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: spacemancw | last post by:
I'm reading an article on MySQL/PHP at http://hotwired.lycos.com/webmonkey/99/21/index3a_page4.html?tw=programming It's very good for me starting out but I have a question. I'm using OS X...
8
by: David Hitillambeau | last post by:
Hi guys, As I am new to Python, i was wondering how to declare and use global variables. Suppose i have the following structure in the same module (same file): def foo: <instructions>...
5
by: duikboot | last post by:
Hi all, I'm trying to export a view tables from a Oracle database to a Mysql database. I create insert statements (they look alright), but it all goes wrong when I try to execute them in Mysql,...
4
by: Terencetrent | last post by:
I having been using Access '97/2002 for about 4 years now and have never really had the need or the time to learn visual basic. Well, I think the time has finally come. I need help with Visual...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
28
by: Siv | last post by:
Hi, If I run the following: strSQL = "Select * FROM Clients;" da = New OleDb.OleDbDataAdapter(strSQL, Conn) 'Create data adapter cb = New OleDb.OleDbCommandBuilder(da) ...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
3
by: congngo | last post by:
Below is my code. What I want do is ,after running the insert statement into tblarchive, I want to go to the subform and set focus to the record that I just added in Confirm = "'" + CONF +...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.