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.FileDial og" 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 - Private Sub btnImportData_Click()
-
-
Dim dlgPickFiles As Office.FileDialog
-
Dim strFileName As String
-
-
Set dlgPickFiles = Application.FileDialog(msoFileDialogFilePicker)
-
-
With dlgPickFiles
-
.AllowMultiSelect = False
-
With .Filters
-
.Clear
-
.Add "Excel files", "*.xls"
-
End With
-
.Show
-
strFileName = .SelectedItems(1)
-
End With
-
-
Set dlgPickFiles = Nothing
-
-
With DoCmd
-
.TransferSpreadsheet acLink, acSpreadsheetTypeExcel9, _
-
"tblTempLink", strFileName, False, "Data Output!A2:C2"
-
.RunSQL "INSERT INTO [TBL Import_Excel] (Sponsor, Owner, Project_Name) " & _
-
"SELECT tblTempLink.Sponsor, tblTempLink.Owner, tblTempLink.Project_Name " & _
-
"FROM tblTempLink;"
-
.DeleteObject acTable, "tblTempLink"
-
End With
-
-
End Sub
3 2387 kadghar 1,295
Recognized Expert Top Contributor
Hi
(...) message for the "Dim dlgPickFiles As Office.FileDial og" 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.Fil eDialog(msoFile DialogFilePicke r)
.filters(...)
.selection(...)
end with
That'll do
What about the syntax error for the "INSERT INTO" statement?
Is it possible you misspelled a field name? Or perhaps the import is not setting the field names correctly.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 Panther 10.3.2
MySQL 4.0.15
PHP 4.3.2 (cli) (built: Sep 13 2003 22:04:20)
|
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>
<instructions>
def bar:
<instructions>
|
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, because the dates must have
quotes on each side.
I just don't know how make the dates right.
Well I'll just show you the code and some insert statements it generates.
Could anyone please help me?
|
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 Basic code that will examine numeric value for
a particular field in a query, and assign a new numeric vaule to that
field. There are over 21 possible values and I am told that IIF
statement will only handle 9 of the possibilities and that I need...
|
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 for long running reports. When
the processing is complete it uses crystal reports to load a template file,
populate it, and then export it to a PDF.
It works fine so far....
| |
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) 'Create command builder using the datadapter
dt = New Data.DataTable
da.Fill(dt) 'pour in the data using the adapter
|
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 attach this script
files and inq files. I cant understand this error. Please suggest me.
You can talk with my yahoo id b_sahoo1@yahoo.com. Now i am online.
Plz....Plz..Plz...
|
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 + "'"
usr = "'" + CurrentUser() + "'"
strSQL = "INSERT INTO tblarchive ( conf, csrID, csdate, comments )
SELECT " & Confirm & " AS Expr1, " & usr & " AS Expr2, Date() AS
Expr3, 'cxl' AS Expr4;"
|
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 - I have read every post out there
and spent hours trying to figure out the problem with no success whatsoever -
I have constrained the problem to one form however, and I think it's hiding
somewhere in my code associated with this form, which is...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| | |