Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can access the record in two ways, both of which require you to use a Form rather than the Table GUI. You can use a columnar form that looks exactly like the table GUI.

There probably is a way to explore down through the object hierarchy to figure out how to get the information from the table GUI, but I would not recommend spending the time trying to figure it out. If you still insist on using the Table GUI for this do MsgBox ThisComponent.DBG_properties and then explore up the object hierarchy (e.g. Parent) and down (e.g. getByIndex(0)) until you find whatever it is that has the data. You will find this to be time consuming and confusing, but if you are persistent eventually you may well find it.

If, on the other hand, you will switch to a Form:

Option A: alter the values of data in controls on the open form. For the simple principles involved, here is an example. Once you access a value from a Form Control, you can manipulate the data in Basic. To execute your vision, you could make all of the changes in the form controls, assuming you just want to change the current record. Note that numeric, date, and text controls all have different properties and methods, and date in particular is an UNO object, so look around for various recipes of how to access those objects, or explore the .DBG_methods and .DBG_properties of the objects. When you commit the whole record, the new values that committed to the various controls will be saved to the table.

Option B: alter the values directly in the underlying table using a SQL query, and then reload the form record. For an example of SQL queries in a macro, see this example. That query also shows the structure of a UNO date object. Instead of the SELECT query there, you would do an UPDATE query, or whatever was desired, with the limitation to the primary key of the record you want to change. Then .reload the form and move it back to the correct record if necessary, which is the last code example in this answer.