473,509 Members | 2,526 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Complicated VB Coding and SQL. Please Help!

129 New Member
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, 223 views)
Aug 2 '08 #1
1 1673
Stewart Ross
2,545 Recognized Expert Moderator Specialist
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
1672
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
1512
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
1729
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
1489
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
1812
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
6315
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
1786
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
1352
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
1350
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
2133
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
7233
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
7342
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
7410
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
7505
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...
0
5650
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,...
0
3215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
440
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.