This is a table that I set up to illustrate some of the concepts in
maintenance.
Now I am going to look at the BeforeUpdate Query that I created to see the
records that have a client amount > 5000.
Now I am going to do an update. I want to increase the client amount by 10% for clients that meet the criteria of >=5000.
First I clicked on the Update Icon and you can see that Update To: got included
in the design view of the query. Now I need to put in the formula I want to
use. Then I will click on Run to see
the results.
Note that I am multiplying the ClientAmount which I enclosed in square braces
by 1.1.
On the update column under ClientAmount, I entered the formula [ClientAmount]*1.1. Now I click on run.
Note that it comes back and tells me that I am about to update 3 rows and asks
for confirmation.
I click on Yes and the update is executed.
This shows the updates that took place. Guess I should not have continued with
the Query named BeforeUpdate. Because
it is now AfterUpdate. Oh well... Here is the table!
Now I am going to look at the SQL behind the update BeforeUpdate.
UPDATE
Table1 SET ClientAmount = [ClientAmount]*1.1
WHERE ClientAmount >= 5000;
I can eliminate the square braces since there are no embedded spaces in the field name.
UPDATE Table1 SET ClientAmount = ClientAmount * 1.1
WHERE ClientAmount >= 5000;
I just eliminated a few things that are not required since I am dealing with one table and one condition etc.
Now I want to delete a record from the table. I will delete the record with ClientIdno = 12345. Note that when I click the Delete Icon, the Delete Where shows up on the query.
When I click on Run, I get asked if I want to go through with the delete.
I click on Yes and the record is deleted. Note that when I look at the table, I
see deleted in the columns. Refresh will take care of that and I will see only
the records that remain.
Now I am going to look at the SQL code that was generated.
This can be written as:
DELETE *
FROM Table1
WHERE ClientIdno=12345;
I did this to delete another record with 11111
DELETE *
FROM Table1
WHERE ClientIdno=11111;
You can also use SQL to insert a record into the table. In this case I started a query and put
nothing into it. Then I wrote the
insert and clicked on run.
The record got inserted after I clicked Yes.