Ask Your Question
0

How to create Base form to enter values for row update?

asked 2016-07-09 07:05:37 +0200

jvglynnjr gravatar image

I want to create a form with 2 text boxes in it for data entry into a single table. The 1st will contain the primary key and the 2nd will contain an integer to update for another column in that row.

In other words:
[ type primary key here ] [ type integer here ] then pressing ENTER will run the update query with these 2 variables, then reset the form.

Can Libreoffice Base do this? I know that I will need to script the SQL statement, but I don't even understand how to make the form have fields for variables.

Any hints appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2016-07-09 08:59:42 +0200

pierre-yves samyn gravatar image

updated 2016-07-12 14:23:42 +0200

Hi

It is not necessary to create a specific one. Forms have the Filter feature:

1 - Click the tool Form-Based Filters

Filter1

2 - Type the searched value in its text box, apply the filter, Filer2

3 - Update the record.

4 - Unapply or Reset the filter. Filter3

[EDIT]

Without macro would be possible to create a form with a subform. In the main form you type the ID and the link is made to display the related record in the subform. However this requires adding a macro to avoid having to accept the entry in the main form (and allow the update of the subform).

So, since it takes a macro, the easiest way is to entirely program. In the UpdateForm.odb attached the form is based on the Invoices table.

The macro begins with three constants that define the name of the table and the fields concerned. Simply adjust these constants: name of table and fields to be processed (and of course change the source of the form).

Warning: to meet the "specifications", no validation is required before updating data. Only messages in case the fields are empty and that the ID is not found.

  • InitForm procedure called when loading form
  • UpdateQuery procedure called when key pressed (Enter key) in the "Integer" field

Regards

edit flag offensive delete link more

Comments

Thanks, Pierre, but that won't work. I need the form to pass 2 parameters to an UPDATE query when the user enters a number and carriage return. (I'm actually using a barcode scanner, which does the equivalent). I can't have the user mucking around with clicking on buttons like filters.

This is really easy to do with the form builder in Access, but I can't figure out how to get libreoffice to do it. So how do I get a text box on a form to give me input to my script variable?

jvglynnjr gravatar imagejvglynnjr ( 2016-07-10 18:12:43 +0200 )edit

Thanks for going to all the trouble of creating an example! I'm looking at your form in edit mode, but I'm not sure how to get to the macros. The control menu doesn't seem to work.

jvglynnjr gravatar imagejvglynnjr ( 2016-07-13 04:18:43 +0200 )edit

To edit the macro: ToolsMacrosOrganize MacrosLibreOffice Basic (or Alt+F11) then unfold UpdateForm.odbStandardModule1

pierre-yves samyn gravatar imagepierre-yves samyn ( 2016-07-13 08:20:19 +0200 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2016-07-09 07:05:37 +0200

Seen: 1,290 times

Last updated: Jul 12 '16