473,396 Members | 2,076 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.

Complicated VB Coding and SQL. Please Help!

129 100+
I am wanting to import CSV files into Access, which isn't a problem at the moment the code i have is as follows:

Dim strSQL As String
Dim CSVTable As String
Dim FilePath As String
Dim Result As String

strSQL = "DELETE * from csvordlin"
CSVTable = "csvordlin"

FilePath = InputBox("Please Enter a Path File for the CSV Location!", "Criteria Required")
If FilePath = "" Then
Else
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
DoCmd.TransferText acImportDelim, , CSVTable, FilePath, False
Result = MsgBox("You have Successfully Imported your chosen CSV file!", vbInformation, "Import Status")
End If

This successfully imports details into csvordlin table. Attributes such as StkID, Qty, Description, Height, Width and Depth are contained within. I am wanting to transfer these details into an existing table called "ordlin" (OrderLine) for an particular order but it needs check parameters such as if a certain StkID does not exist within the "stkmas" table then provide the option to ADD these Details to the "stkmas" table with an INSERT statement.

I have created a Customer Order Form where there is an OrderHeader and OrderLine contained within. I have OrderNo set as the Primary Key for the OrderHeader and OrderNo and StkID for the OrderLine so i can have many lines for one OrderHead.

So as a Step-by-Step approach, i am wanting the following to happen:

1. Create the OrderHead
2. Click on a Button to Import the CSV file as shown above.
3. Check the Imported Data exists within existing Stk file.
4. If not have the option to add to the existing Stk file.
5. Import the data into the Form OrderLine where it will have to assign an OrderNo with each row of data.
6. Assign correct Stk ID's or (New ones) with the Stk Descriptions imported. (Will explain below **).
7. Assign any Price that belongs to the existing "stkmas" table. (D-LOOKUP most likely)

This is my crappy attempt of transferring the data from the csvordlin table to the ordlin table:

Dim strSQL As String

strSQL = "INSERT INTO ordlin(StkID,Qty,Width,Depth,Height)SELECT F1,F4,F5,F6,F7 FROM csvordlin"

DoCmd.RunSQL strSQL

It didn't work as u may know. F1 = StkID, F2 Stk Description, F4 = Qty, F5 = Width, F6 = Depth and F7 = Height.

** When sorting this database out i assigned StkID's to Stock Items, where as the Imported data uses the StkDesc as there IDs, so i am gonna have to match my StkShortDesc with there StkID as they dont use numbers. For example;

StkID = 133, StkShortDesc = Base, Qty = 1 - Mine
StkID = Base, StkDesc = Base Board, Qty = 1 - CSV File (Theirs)

My Visula Basic is limited when trying to do something like this and is a bit out of my league as you could probably tell. Any help would be greatly appreciated.

Thanks in advance!
Attached Images
File Type: jpg Untitled.jpg (29.7 KB, 222 views)
Aug 2 '08 #1
1 1669
Stewart Ross
2,545 Expert Mod 2GB
Constantine Al, you posted a virtually identical thread to this one the following day. As there has been one reply to that thread I will close this one to avoid confusing experts who may try to answer the same two threads. I would simply have deleted this unanswered thread were it not for the screenshot which is not in the other thread.

Please do not double post your threads in the future; they will not be answered any faster if you do.

Double posting is against the posting guidelines published at the top of the forum.

MODERATOR
Aug 3 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Igorati | last post by:
Ok, this is what I have so far: #This program will ask for a user to imput numbers. The numbers will then be calculated #to find the statistical mean, mode, and median. Finallly the user will be...
7
by: mx2k | last post by:
Hello @ all, we have written a small program (code below) for our own in-developement rpg system, which is getting values for 4 RPG-Characters and doing some calculations with it. now we're...
6
by: Igorati | last post by:
I need some ideas of how to accomplish this task. I was told that I just need to save the input in a file and make the file searchable, nothing fancy like tying into SQL or Oracle. THis is a basic...
5
by: Norma | last post by:
I am trying to make a query pull data from between the dates I enter in the parameter but also look back 'in time' to see where 2 other fields have null values, and only pull data into the query if...
1
by: Stephen | last post by:
Was wondering if someone could please help me with an array I'd like to create in an asp.net page. I have to design an array which stores the values of addresses manually entered into textboxes...
12
by: kalinga1234 | last post by:
hy guys i am having a problem with my sudoku program which i coded using c++.; currently in my program if a duplicate number exist in either row/column/block i would make the particualr square...
0
by: riflefire | last post by:
Hello Everyone, I am using the new MITE c# text game engine to code up a MUD style game. I need a lot of help as i am new to C#. The reason i need the help is that the engine requires c# scripts to...
1
by: phill.luckhurst | last post by:
I've now got a form that will output to a MySql database as you can see here. http://www.windsurf.me.uk/form166/form.html Obviously the graphical look needs work. I am then using a...
2
by: kakaria | last post by:
hey guys, i dont know anything about coding in access. can u give me some guide lines, like how to open some form using a button in another forn, and how to create a form in which data can be...
15
by: bananahead | last post by:
Hello PHP Pros! I need some help with this complicated problem! I have looked into how to do arrays but Im a bit confused on this one. I have a table in the following format: visitor_ID |...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
isladogs
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...

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.