Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Previous Record Fill?

Status
Not open for further replies.

KeRouAZY

Programmer
Joined
Nov 29, 2001
Messages
8
Location
US
Hi, I have a database, based on an import of a text file in which the output looks like the following format


field 1 field 2 Field 3 Field 4
page 1 <Null> <Null> <Null>
<Null> &quot;Item 1&quot; &quot;Desc. 1&quot; &quot;Price&quot;
<Null> &quot;Item 2&quot; &quot;Desc. 2&quot; &quot;Price&quot;
<Null> &quot;Item 3&quot; &quot;Desc. 3&quot; &quot;Price&quot;
page 2 <Null> <Null> <Null>
<Null> &quot;Item 4&quot; &quot;Desc. 4&quot; &quot;Price&quot;

I want to have the nulls in field 1 filled in with the page number that is above it. Is there a way to do this? I know that I can manually just go down the line in every blank field and do a &quot;CTRL-'&quot;, but with 600 pages and thousands of items(4000+ rows), this would be very time consuming.

Any suggestions would be appreciated.

Thanks,
-Bill

 
using dao
this code will
open the record set
look at field1
if it is not empty it assigns then page to pagename variable
it then puts the pagename in field1
so in the way you displayed the data pagename will become &quot;page1&quot;, it will then place &quot;page1&quot; in the first record
it will move to the next record it is null so it pagename is still page one so it place &quot;page1in record2. it continues to move thru the recordset until it come to the 5th record, page2 now pagename becomes &quot;page2&quot; it continuce to do this until it reaches the end of the recordset.
put on a button click event or something like that good luck


dim pagename as string
dim rst as recordset
dim db database
set db= currentdb
set rst = db.openrecordset(&quot;yourtablename&quot;)
with rst
.movefirst
do until .eof
if !field1 <>= &quot;&quot; then pagename = !field1
.edit
!filed1 = pagename
.update
.movenext
loop
.close
end with
set rst = nothing
set db = nothing

 
problem with above code noticed after posting

if !field1 <>= &quot;&quot; then pagename = !field1
should read
if !field1 <> &quot;&quot; then pagename = !field1
sorry
 
I think that I am the one who is braindead here...... And I should have mentioned, I'm a newbie...

would this be through a query? A module? How would I set this up and get it to run...

Thanks for all your help...
 
I think I got it... I made the code a module... Then I had a macro to run the module... Is this a good way of doing it?

Hope so, It does work...

Thanks again for all your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top