Ask Your Question

Base Macro to update a field in table

asked 2019-02-06 13:36:47 +0200

Zoarsk gravatar image

Hi, I am stuck on what I assume is something obvious, I’m not that familiar with Base so apologies. I am working on a Corporate db so can’t show the code, so have a made up db for this example.

The DB is “DB1”, with a table “tblTable1” which has two fields “A” and “B” both integers, “A” has values in it and “B” is empty, there is no primary key! What I’m trying to do is write a macro that steps through each record in turn, reads in the value of “A”, does some clever maths! In this case just adds two, then updates the “B” field in that record with the answer, then moves to the next record etc etc.

I have done most of the code which seems to work until I try to update “B” then I get an error about the table being Read Only, which I can’t get around. I haven't included any code as I’m interested to see what someone who knows what they are doing would do.

Any help greatly appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2019-02-06 14:52:17 +0200

peterwt gravatar image

updated 2019-02-07 17:39:13 +0200

Are you using Base embedded database? You can't enter data in a table unless it has a primary key. How did you get data into field "A"?


If when creating a Table you do not set a primary key you will get an error when saving the Table stating that a primary key has not been created and that data can't be entered. Did you not get this error when you created a Table without a primary key and saved it?

edit flag offensive delete link more


Good questions: Database is Firebird embedded. In this example I entered some 9 or 10 rows of data manually into “A” in the real db the data comes from monitoring software directly. At the moment there is no primary key in either db, that may change later.

Zoarsk gravatar imageZoarsk ( 2019-02-06 19:52:33 +0200 )edit
Login/Signup to Answer

Question Tools


Asked: 2019-02-06 13:36:47 +0200

Seen: 278 times

Last updated: Feb 07 '19