|
|
||||||
|
#1
|
|
|
|
|
Hi,
Would this also apply to my situation: I need to parse a long text field (imported from a very old database format) which will contain 0 or more 13-character blocks of text. These blocks represent status update entries; each begins with "!!" but does not have any delimiters at the end of the block. I have no experience with the Split() function in Access VBA, and the last time I worked with arrays was a good 20 years ago. I had written an event procedure parsing the blocks in a single record and appending them to a second table using a foreign key to relate the two tables. I used the Mid() function in my loop to process the string field character by character. Now I am faced with the task of processing the entire table at once. So far, it looks as though the way to go is to use VBA and recordset operations (with which I have very little experience, being more SQL oriented), to unpack the status blocks into a temporary table containing the ID and the string, just to keep this step simple. After creating this temp table, I would call an append query using Mid() to unpack the status block into the appropriate fields of the status table. Thanks in advance! "John Nurick" wrote: [..] |
|
|
|
#2
|
|
|
|
|
JMHO here, but it would seem to be much easier to simply use ADO methodology
to do the entire thing. You have complete control over each step of the process, and unlike a SQL query, you can single-step through the code to make sure each element is being parsed correctly. "mary r" wrote: [..] |
|
#3
|
|
|
|
|
The Split function would be exactly the thing to use in this case. It is
not that difficult and the fact that there is no delimiter on the end makes it even easier. If it did, the resulting array would have a null element at the end. As to working with arrays in Access. It really isn't hard. You do have to be aware of the Option Base statement. Option Base determines whether array elements start with 0 or 1. The default is 0, so it will always be 0 unless you have Option Base 1 specificed at the top of your module. So, the array index will be 0 to the number of elements -1. It is just like many of the property collections in Access. There is also the Ubound function that will tell you what the highest element index is. If you are using Option Base 0 and there are 6 elements, the Ubound function will return 5. So if you need to create a record for each element, here is a general outline to get you started: Dim varMyArray As Variant Dim lngX as Long Dim rst As DAO.Recordset Set rst = Currentdb.OpenRecordset("SomeTable") varMyArray = Split(BlockOfStrings, "!!") With rst For lngX = 0 to UBound(varMyArray) .AddNew !BlockField = varMyArray(lngx) .Update Next lngX .Close End With Set rst = Nothing Like I say, this is just an outline, I am sure there will be more to do, but hopefully, this will get you started. Good Luck! "mary r" <maryr> wrote in message news:6045 [..] |
|
#4
|
|
|
|
|
Dennis, thanks for your reply. I have very little experience and no training
in ADO, being a dinosaur who still remembers flow charts and linked lists :-) "Dennis" wrote: [..] |
|
#5
|
|
|
|
|
Thanks very much, Klatuu. I think I can move forward with this now. Have a
great day! "Klatuu" wrote: [..] |
|
|
| Similar Threads | |
| extract items from filtered list I need to set up a report that dynamically displays on another sheet items from one column of a filtered range. After the advanced filter is executed, I may have 12 records... |
|
| extract items from list in single field I have a table with fields IndividualID, ItemList. ItemList is a single text field that has items separated by a comma (e.g., "apple, orange, lemon, lime"). I need to... |
|
| Extract Field Values from Multiple records for a single criteria Not quite sure how to explain this. I have orders in a table that can get shipped from a multitude of warehouses (13 potential to be exact) spanning many records. Out of... |
|
| Extract only items not on previous list Suppose you have two lists: a, b, c, d, e, f, g and a, b, e, g and you want to extract only the items on the first list that are not on the second list. |
|
| Extract single items from a list Hi, Is there a way to extract a short list of single items from a longer list of items? Example: If I have an Excel Sheet with the following cells filled a a a b |
|
|
All times are GMT. The time now is 01:14 AM. | Privacy Policy
|