473,395 Members | 1,668 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,395 software developers and data experts.

Import File Module

natalie99
Hello everyone

I have come to the point where I think I need to write a module to finish the last steps of my db. Can anyone please give me their advice / oppinion on the4 easiest way to do this, I have NEVER written a module beofre, I know what they look like, but I do not know the diffference between Private Subs etc etc - help!

My aim is very simple:

Have a form with a browse for file command button, then a command button which will upload the data to an already existing table but it must OVERWRITE the data, NOT append.

I have thus far got this:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferSpreadsheet transfertype:=acImport, _
  2.             tablename:="tblBTM", _
  3.             FileName:="P:\Fin\B_SHEET\COMMS\NIMS\Investigation\New MACS\MARCH 08\BT_MACS_MAR07_MAR08.xls", Hasfieldnames:=True, _
  4.             Range:="'BT_MACS_MAR07_MAR08'!", SpreadsheetType:=8
  5.  
but I don't know what to do with it, and this does not incorporate the browse function :(

pls help :D

nat
Apr 11 '08 #1
4 1916
NeoPa
32,556 Expert Mod 16PB
When you say overwrite the data, do you really mean that ALL the original data should be replaced by the new? As opposed to records with matching keys replacing only those records in the table?
Apr 11 '08 #2
NeoPa
32,556 Expert Mod 16PB
The code for clearing the table prior to the import process (add before line #1 of your code) would be fairly straightforward :
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.SetWarnings(False)
  2. Call DoCmd.RunSQL("DELETE FROM [tblBTM]")
  3. Call DoCmd.SetWarnings(True)
Apr 11 '08 #3
Thanks Neo

Sorry if I wasn't clear enough, I meant that, the table needs to be replaced, completely, which means that, the field names may change, the data will all change, the only items that won't change will be the field names related to my queries.

So, in effect it would be like the Do you wish to replace the query or table 'tblBTM'? prompt box that appears if you import the file and then select new table, then name it the same as the old table.

I am trying to have the format standardized to fix this so I can run your delet code (thanks again for the help) so fingers crossed someone sees my logic!

:)

Nat
Apr 16 '08 #4
NeoPa
32,556 Expert Mod 16PB
Nat,

It is possible to run a MakeTable query in Jet (Access) SQL too, but I recommend the clear / add approach over the Delete / MakeTable one if at all possible.
Apr 16 '08 #5

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

Similar topics

0
by: Stian Søiland | last post by:
all examples performed with: Python 2.3+ (#2, Aug 10 2003, 11:09:33) on linux2 (2, 3, 0, 'final', 1) This is a recursive import:
4
by: Steve Holden | last post by:
I'm trying to load module code from a database, which stores for each module its full name, code, load date and a Boolean indicating whether it's a package or not. The following simple program:...
5
by: Steve Holden | last post by:
This is even stranger: it makes it if I import the module a second time: import dbimp as dbimp import sys if __name__ == "__main__": dbimp.install() #k = sys.modules.keys() #k.sort() #for...
4
by: MackS | last post by:
Hi I'm new to Python, I've read the FAQ but still can't get the following simple example working: # file main_mod.py: global_string = 'abc' def main():
16
by: didier.doussaud | last post by:
I have a stange side effect in my project : in my project I need to write "gobal" to use global symbol : .... import math .... def f() : global math # necessary ?????? else next line...
7
by: Ron Adam | last post by:
from __future__ import absolute_import Is there a way to check if this is working? I get the same results with or without it. Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) on win 32 ...
6
by: bvdp | last post by:
I'm going quite nutty here with an import problem. I've got a fairly complicated program (about 12,000 lines in 34 modules). I just made some "improvements" and get the following error: bob$ mma...
3
by: Caren Balea | last post by:
Hello, I'm newbie to python. So far, I'm a bit disappointed. It's awful to set Python up to work. It's not working!!! Ok, calm down. Here are my settings: I'm using Windows XP machine and...
10
by: Thomas Guettler | last post by:
If you look at this code, you see there are two kind of ImportErrors: 1. app_name has no attribute or file managment.py: That's OK. 2. managment.py exists, but raises an ImportError: That's not...
10
by: nisp | last post by:
Hi all ! I'm trying to capture stderr of an external module I use in my python program. I'm doing this by setting up a class in my module overwriting the stderr file object method write. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
Oralloy
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,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.