[Example] Updating in a gridcontrol with macros

Some examples to be used directly
Forum rules
No question in this section please
For any question related to a topic, create a new thread in the relevant section.
Post Reply
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

[Example] Updating in a gridcontrol with macros

Post by RPG »

Hello

This is an example how to change data in your database. It use macros and I suppose you also use the filter of the form where the grid control is.

There are two methods how it can work
a) Works on all records of the grid control.
b) Works only on the selected records of the gridcontrol.

For both methods:
a) The table must editable
b) The filter limits the records who will be changed

This method of updating your database is not the most preferred method. I think this is good for when you need to change some records. When you have to change a great number of records then I think SQL is better.

I have two examples:
a) for updating a grid control.
b) for copy values in one gridcontrol to an other gridcontrol.

Before you use in for a real production check this out. I did only test it a little


Romke
Attachments
vbGridForTwo.odb
(59.82 KiB) Downloaded 2465 times
Last edited by RPG on Sun Apr 03, 2011 11:03 am, edited 2 times in total.
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Example Updating in a gridcontrol with macros.

Post by RPG »

Hello

I have made it a little more flexible. That means when you select a column in the table then you can change the field what must be updated. So you can now select all columns and update that field.


It is true not all kinds of controls I have implemented but maybe they come later.

I do now add a writer document and not a database document. The reason is I have changed to LibereOffice 3.3 and that give problems. You can use this document in combination with the earlier example.

When you want use it in your own database do test it good before you use it in real important databases. I test it only in the database I did post.

Romke
Attachments
vbGridForTwo.odt
Example how to update fields with help of macros in a grid
(20.08 KiB) Downloaded 1621 times
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Example : Updating in a gridcontrol with macros.

Post by RPG »

Hello

When you want use this example then you have also to download the complete database in the first post of this thread. This database must be registered and then you need to bind this form to the database.

I also believe that when you have an own database and you want use a form with a grid table you can use your own database.

Bind the form to the database and table or query you want. Make a new grid control but keep the name of the original grid control. Do not change the other control or the macros. I believe it must work but I have not test it.

What I have change now.
For the date control you cannot only change the data to an other date but you can add days,weeks,month or years to the date. Now I knew how I can change a date control in this way I can maybe also change other kinds of control in the same way. But I have on this moment no idea what is important.

Slow
Again this is not for updating a great number of records but only some records.

Selecting
When this form is a little more complicated in the way it is a subform and not a mainform and you do all kind of selecting in the mainform then I believe it can work but not now. The reason: It is more a little problem about finding the good form with giving the names to the form and the control. In other word I believe there is no principle problem.

This is made you have not to change the macros but you need a little knowledge about forms.

Romke
vbGridForTwo08.odt
Updating with a form
(23.71 KiB) Downloaded 1846 times
Post Reply