473,395 Members | 1,987 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 parent/child from txt file

I am creating an inventory database where I need to import data from a text file created by a barcode scanner. The software associated with the scanner saves scanner data as a text file that looks something like this:

1234561235
12335
12365
45645
1234567895
12398
45659
4567890123
12397

The 10 digit codes are the barcodes for the location where the equipment is. The following 5 digit codes are the barcodes of the equipment in the location scanned above.
I would like to set up an import parent child relationship so that the equipment is associated with the location. I have limited access/coding experience but I pick things up quickly.
Let me know if you guys have any ideas. I realize this could get complicated.


Much thanks,
SSgt Jonathan Glass
USAF
May 14 '07 #1
2 1843
Rabbit
12,516 Expert Mod 8TB
I am creating an inventory database where I need to import data from a text file created by a barcode scanner. The software associated with the scanner saves scanner data as a text file that looks something like this:

1234561235
12335
12365
45645
1234567895
12398
45659
4567890123
12397

The 10 digit codes are the barcodes for the location where the equipment is. The following 5 digit codes are the barcodes of the equipment in the location scanned above.
I would like to set up an import parent child relationship so that the equipment is associated with the location. I have limited access/coding experience but I pick things up quickly.
Let me know if you guys have any ideas. I realize this could get complicated.


Much thanks,
SSgt Jonathan Glass
USAF
Well, you're going to have to write a procedure that opens the text file, reads and stores the first number, which should always be ten digits, then it reads the next line and together those two get put into a table that has two fields, one a location field and the other the equipment field. Then it continues doing this until it finds another record with a 10 digit number, at this point, the new number replaces the old one and continues along until the end of the file is reached.
May 17 '07 #2
nico5038
3,080 Expert 2GB
You could create a function like:

Expand|Select|Wrap|Line Numbers
  1. Function fncGetImportData()
  2. 'This function imports a file from disk like:  "D:\Data\myfile.txt"
  3. 'Into two tables
  4.  
  5. Dim rsL As Recordset
  6. Dim rsI As Recordset
  7. Dim strLine As String
  8. Dim strLocation As String
  9.  
  10. Set rsL = currentdb.OpenRecordset("tblLocation")
  11. Set rsI = currentdb.OpenRecordset("tblItem")
  12.  
  13. Open "D:\Data\myfile.txt" For Input As #1
  14.  
  15. While Not EOF(1)
  16.    Line Input #1, strLine
  17.    ' This test is used to skip empty lines..
  18.    If Len(strLine) > 0 Then
  19.      ' process 10 and within that the 5 long records
  20.       If Len(strLine) >= 10 Then
  21.          ' add location record
  22.          rsL.AddNew
  23.          ' save loaction for details
  24.          strLocation = Trim(strLine)
  25.          rsL!Location = Trim(strLine)
  26.          rsL.Update
  27.       else ' not 10 so we assume 5 long...
  28.          ' add Item record
  29.          rsI.AddNew
  30.          ' location
  31.          rsI!Location = strLocation
  32.          rsI!Item = Trim(strLine)
  33.          rsI.Update
  34.       end if
  35.    End If
  36. Wend
  37. Close #1
  38.  
  39. Set rsL = Nothing
  40. Set rsI = Nothing
  41.  
  42. 'As all is "invisible" just a reminder when file has been processed...
  43. MsgBox "Table import ready"
  44.  
  45. End Function
  46.  
Just copy paste the code into a module and change the filename.

Nic;o)
May 19 '07 #3

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

Similar topics

3
by: Jim | last post by:
I would be very grateful for help on the following. I have the following modules in a program. Names changed to protect the innocent. 1.Simulation 2.Branches 3.MyFiles I import Branches,...
1
by: Joe D | last post by:
I think this is a simple question. But I am new to JS. Here is what I want to do: From a parent window, open a popup window (child) to get data from user, then user submit the request, close the...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
3
by: Eddie | last post by:
If FormMain = MDI parent, FormSub = Child parent, I execute FormSub from the menu like this way. FormSub^ sub = gcnew FormSub; sub->MdiParent = this; sub->Show(); This can generate child...
4
by: raj_genius | last post by:
I hav two queries, whc are as follows: FIRSTLY: is it possible to access the controls(by name) of a parent form(MDI) from its child forms??if yes then how??plzz provide a coded example in VB if...
1
by: wlevins | last post by:
I have a simple script which has worked flawlessly for years - it copies a bit of data from a child window down into a form field in the parent window that opened the child. But now in Firefox 2.0...
2
by: SSgtGlass | last post by:
I am creating an inventory database where I need to import data from a text file created by a barcode scanner. The software associated with the scanner saves scanner data as a text file that looks...
3
by: zacks | last post by:
Forgive me if this has been already asked an answered, I did do a search both here and in VS2005 Help, but I can't find the answer to my question. I am developing an MDI application that is a...
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:
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
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...
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
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
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
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.