473,385 Members | 1,472 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,385 software developers and data experts.

copy field above if current field is null

Is there a way to copy the data from a field above the field I am in (Access 2000 query) only if the current field is empty. And then when the current field has a new value in the field above, copy that data? For example, records as follows, and I want to copy "cats" until it becomes "dogs", then copy "dogs" until it becomes "parrots", etc.

cats blue
black
orange
brown
white
dogs black
brown
parrots green
red
blue

I do not know any programming language, but thought I could do an IF statement in the query, like If animal name is null, Ctrl + ", animal name. Is it possible? Thanks.
Jul 3 '07 #1
2 4605
nico5038
3,080 Expert 2GB
Can be done with a query when using a trick.
1) Add an autonumber ID field with increment +1 to your table
2) Create a query like:
Expand|Select|Wrap|Line Numbers
  1. SELECT [ID]+1 AS ID1, Table1.Animal, Table1.Color
  2. FROM Table1;
This will "fool" Access when you JOIN the table by the ID / ID1 field
3) Create a query like:
Expand|Select|Wrap|Line Numbers
  1. UPDATE Table1 INNER JOIN qryTable1 ON [Table1].[ID]=[qryTable1].ID1 SET Table1.Animal = [qryTable1].[animal]
  2. WHERE ((([Table1].[Animal]) Is Null));
This will do the work as the animal from the previous row will be replicated.

Getting the idea ?

Nic;o)
Jul 3 '07 #2
NeoPa
32,556 Expert Mod 16PB
You have (accidentally) posted this question in the Access Articles section. This is NOT an article.
I'm moving this to the main Access questions forum.

MODERATOR.
Jul 3 '07 #3

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

Similar topics

7
by: Rick Caborn | last post by:
Does anyone know of a way to execute sql code from a dynamically built text field? Before beginning, let me state that I know this db architecture is built solely for frustration and I hope to...
42
by: Edward Diener | last post by:
Coming from the C++ world I can not understand the reason why copy constructors are not used in the .NET framework. A copy constructor creates an object from a copy of another object of the same...
6
by: Shyguy | last post by:
I want to create two buttons on a form. One would allow the user to Copy the contents of the current records memo field, the other would allow them to print. I set up a report based on the memo...
19
by: davidgordon | last post by:
Hi, I need some pointers/help on how to do the following if it possible: In my access db, I have the following: Tables: Products, Sub-Assembly, Product-Pack Table, Products
4
by: Beow | last post by:
Hello, I'm still very new to C++ and have encountered some trouble in understanding how exactly the copy constructor for a stack class (given as an example in the book I've been learning from)...
1
by: roveagh1 | last post by:
Hi I've been using the 2 year old link below to repeat values from previous record field into current corresponding field. It's worked fine for text but the last piece of advice was to use the same...
6
by: Cliff72 | last post by:
I need to fill in the nulls in the batch field the value from the record immediately preceding the null one ie replace the nulls with the preceding value until I hit a record with a value in...
10
by: ESIS | last post by:
Hi, I am trying to create a "simple" application, of which, one of the functionalities is to be able to view a PDF Image (Invoice) held in a BLOB field on an SQL Database in the web browser. As...
1
by: darendaren88 | last post by:
I have created this table: mysql> describe acount; +----------+---------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra |...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.