Unusual (1 Viewer)

Beerbrewer

Registered User.
Local time
Today, 12:35
Joined
Jul 18, 2002
Messages
22
I have a report imported from a text format into Access. The problem is that double values are left blank. The first field is numbered and each number concerns one item. It is necessary to add numbers to the blank lines in my Access table for processing the data properly. How could this be achieved (in VBA)?
It looks like this
1 <InformationA>
<InformationB>
2 <InformationC>
etc.
And must look like this:
1 <InformationA>
1 <InformationB>
2 <InformationC>
etc.
Many thanks
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 06:35
Joined
Feb 28, 2001
Messages
27,254
You don't give enough info for me to be sure.

What format does the text file use? Comma-delimited? Space-delimited? Something else?

The Access "Import From Text" wizard usually wants to see either a fixed-column file format, or else it wants a delimiter such as a comma between adjacent but separate fields. If your file does not meet either condition, then your problem is that the import wizard is confused by your data. The described behavior is consistent with exactly this problem.

You can probably retro-fit this data set with entirely too many hand-generated queries once you do your import, but I infer that you want a more rigorous solution that allows you to do this more than once and to do it with less work.

If my inference is correct, I'm afraid that unless you have either a fixed field width for all fields, or a dependable field separator character (which I call a delimiter), you will have a difficult problem ahead of you.

So the first problem is determining your input file specifics and what changes can you make to the input file if it doesn't match either format I suggested?
 

Beerbrewer

Registered User.
Local time
Today, 12:35
Joined
Jul 18, 2002
Messages
22
Thanks for your replies.
I'm sorry. Probably i have not been specific enough. I have created an linked table. The text file is space-delimited and causes no problems to be "imported" (=through an query appended in an existing table) as a perfect duplicate with valid records. The fields are properly distinguished and also the headers cause no trouble removing them.
There is only one problem: in the original report de duplicate values are left out nut the relation remains obvious. Normally one sees immediately that an empty field has the value of the above. But this is an relation purely based on a format and since in the solely record nothing relates to others when the key value is empy. This relation can thus be created by adding a key value to the empt field equal to the first not-empty field above this record. Since there are no relations between the records SQL seems inappropriate. Therefore i think VBA should be used to loop through the key field in my table and fill the empty ones. My problem is that i do not know how to perform this action.
Here again a better sketch of my table:
FIELD1 FIELD2 FIELD3 FIELD4 etc
1 ........... ........... ........... etc
. ........... ........... ........... etc
2 ........... ........... ........... etc
3 ........... ........... ........... etc
. ........... ........... ........... etc
. ........... ........... ........... etc
4 ........... ........... ........... etc
etc
And below how it should be (empty values replaced):
FIELD1 FIELD2 FIELD3 FIELD4 etc
1 ........... ........... ........... etc
1 ........... ........... ........... etc
2 ........... ........... ........... etc
3 ........... ........... ........... etc
3 ........... ........... ........... etc
3 ........... ........... ........... etc
4 ........... ........... ........... etc
etc
"." stands for no or multiple signs
I am sorry for the long story but i hope this is clear.
Thanks again.
 
Last edited:

Beerbrewer

Registered User.
Local time
Today, 12:35
Joined
Jul 18, 2002
Messages
22
Unfortunately my first table above is not straight. But in my database it is. So Please consider it as a beautiful table.
 

Users who are viewing this thread

Top Bottom