473,325 Members | 2,828 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,325 software developers and data experts.

Acc2K - Read Array into a New Table

MindBender77
234 100+
Hello All,
I'm not very familiar using arrays and found myself getting more confused with each reference source I read. I have an array that I am trying to read into a new table or a temp table.
Here is the function so far:
Expand|Select|Wrap|Line Numbers
  1. Function SplitMemo()
  2. Dim astrMemo,memo
  3. Dim i as integer
  4. memo = Dlookup("[Ordernotes]","tbl_test1")
  5. astrmemo = split(memo,"\")
  6.  
  7. For i = 0 to UBound(astrMemo)
  8. Debug.print astrMemo(i)
  9. Next
  10.  
  11. 'I assume appending the array to a table begins here
  12. End Function
  13.  
Any help is most appreciated,
Bender
Aug 25 '08 #1
5 1964
ADezii
8,834 Expert 8TB
Your details are a little sketchy, but I'll provide you with a Generic Template for populating a Table with Values from an Array. Let's assume you have an Array of Strings consisting of 6 Last Names, and that you wanted to populate a Table named tblNames with these Values into a Field named [Last]:
Expand|Select|Wrap|Line Numbers
  1. Dim astrLastNames(1 To 6) As String
  2. Dim intCounter As Integer
  3. Dim strSQL As String
  4.  
  5. astrLastNames(1) = "Flintstone"
  6. astrLastNames(2) = "Wilson"
  7. astrLastNames(3) = "Johnson"
  8. astrLastNames(4) = "Munster"
  9. astrLastNames(5) = "Reveree"
  10. astrLastNames(6) = "McGettigan"
  11.  
  12. For intCounter = LBound(astrLastNames) To UBound(astrLastNames)
  13.   strSQL = "INSERT INTO tblNames ([Last]) Values ('" & _
  14.   astrLastNames(intCounter) & "');"
  15.   CurrentDb.Execute strSQL, dbFailOnError
  16. Next
Aug 26 '08 #2
MindBender77
234 100+
My apologies for the lack of details and I do thank you for the clarifications. However, I do have a further question concerning Array Usage. Using your example as reference, say that the astrLastNames are populated from a temp table's memo field. What if it is not known that astrLastName(1) = "Flintstone" only that it is the first line delimited from the memo field? Would your template be coded as such?:
Expand|Select|Wrap|Line Numbers
  1. dim memo as string
  2. astrMemo as string
  3. dim astrLastNames(1 to 6) as string
  4.  
  5. memo = dlookup("[Field1]","Table1","[Field1] = some criteria")
  6. astrMemo = Split(memo,"\")
  7.  
  8. astrLastNames(1) = astrMemo(1) ' Is this possible?
  9. 'More code here.....
  10.  
Bender

Expand|Select|Wrap|Line Numbers
  1. Dim astrLastNames(1 To 6) As String
  2. Dim intCounter As Integer
  3. Dim strSQL As String
  4.  
  5. astrLastNames(1) = "Flintstone"
  6. astrLastNames(2) = "Wilson"
  7. astrLastNames(3) = "Johnson"
  8. astrLastNames(4) = "Munster"
  9. astrLastNames(5) = "Reveree"
  10. astrLastNames(6) = "McGettigan"
  11.  
Aug 26 '08 #3
ADezii
8,834 Expert 8TB
My apologies for the lack of details and I do thank you for the clarifications. However, I do have a further question concerning Array Usage. Using your example as reference, say that the astrLastNames are populated from a temp table's memo field. What if it is not known that astrLastName(1) = "Flintstone" only that it is the first line delimited from the memo field? Would your template be coded as such?:
Expand|Select|Wrap|Line Numbers
  1. dim memo as string
  2. astrMemo as string
  3. dim astrLastNames(1 to 6) as string
  4.  
  5. memo = dlookup("[Field1]","Table1","[Field1] = some criteria")
  6. astrMemo = Split(memo,"\")
  7.  
  8. astrLastNames(1) = astrMemo(1) ' Is this possible?
  9. 'More code here.....
  10.  
Bender
Given your unique circumstances and a "\" Delimiter, the syntax would be something like:
Expand|Select|Wrap|Line Numbers
  1. Dim strMemo As String
  2. Dim varMemo As Variant
  3. Dim intCounter As Integer
  4. Dim strSQL As String
  5.  
  6. strMemo = "First\Second\Third\Fourth\Fifith\Sixth"
  7.  
  8. varMemo = Split(strMemo, "\")
  9.  
  10. For intCounter = LBound(varMemo) To UBound(varMemo)
  11.   strSQL = "INSERT INTO tblNames ([Last]) Values ('" & _
  12.            varMemo(intCounter) & "');"
  13.   CurrentDb.Execute strSQL, dbFailOnError
  14. Next
Aug 26 '08 #4
MindBender77
234 100+
Thank you for your assistance, ADezii. With some minor tweaking, things work perfectly.

Thanks Again,
Bender
Aug 28 '08 #5
ADezii
8,834 Expert 8TB
Thank you for your assistance, ADezii. With some minor tweaking, things work perfectly.

Thanks Again,
Bender
You are quite welcome.
Aug 28 '08 #6

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

Similar topics

3
by: deko | last post by:
It's nice to be able to generate an html table from a PHP array. I know how to do this, but the array in question is built from a file. The file in question can be very long, and I only want the...
2
by: Sandman | last post by:
Just looking for suggestion on how to do this in my Web application. The goal is to keep track of what a user has and hasn't read and present him or her with new material I am currently doing...
0
by: Phil | last post by:
I would like to open up an open mdb residing on a remote computer in order to view data. I would prefer that the orig mdb stay exclusive or at least some form of shared as read-only. I keep...
1
by: | last post by:
Can anyone point me to a good resource to show me what potential problems I'll have converting from Access 2000 to Access 2003? I understand that 2003 can read and work with the 2000 files, but that...
7
by: Roman Mashak | last post by:
Hello, All! I wonder is it possible to define an array containing strings, not single characters? What I want is array 'table' that will have N elements, and every element is a strings tailoring...
1
by: alkandry911 | last post by:
hello, Everyone, am new to C Code and I have a little task am trying to achieve: I have a text file with a table of 15*30 which has the following format: ksjdhfbrshyuekjdhsngfurjsleotj...
4
Jezternz
by: Jezternz | last post by:
First of all I am open to any suggestions and advice. If a javscript multidimensional array is a bad way to do this please say so. I considered XML but I wondered if this would be a bad idea as it...
2
MindBender77
by: MindBender77 | last post by:
Hello all, I get an error when trying to run an append query that states duplicate output to a field name. I think because I'm trying to append records to a table that is already in the use. Below...
2
by: jhoelter | last post by:
Hi, First of all, I thank you for reading the following post and taking a little bit of your time helping me figuring this out. I first tryed to explain my exact case, but it is to hard. Let me...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.