Ask Your Question
0

Base Form - Searchbox selection to trigger population of other fields

asked 2015-11-09 08:41:17 +0200

Prong gravatar image

I'm trying to create a database to keep track of in and outgoing stock of our business. I have created a mysql database on our server and used LO as a frontend. I created three tables:

  1. Manufacturers
  2. Products
  3. Stock Change

I need to create a form in which to enter each in and outgoing stock movement. For each such event a couple of fields need to be filled in: SKU, Name, Barcode, Date, Qty in, Qty out. The product can be identified either by SKU or Barcode, so I need to have the SKU and barcode field to show relevant results while typing. Once the wanted product shows up and is selected I want the other other fields to be populated with the information belonging to this product.

I managed to find out how to make the text box a autocomplete search box using the "combo box" option. I need to find a way that the choice of SKU will autopoplulate the other fields. How would I go about that?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2015-11-11 02:57:06 +0200

doug gravatar image

It depends. If the information is wholly determined by the SKU, then the best practice would be not to add it to the Stock Change table at all, and just have the sole information identifying the product be the SKU. In that scenario, you could have a subform (form Navigator --> New --> Form) that displays the Product record, linked to the SKU field. To make this approach really work for live data entry, however, you would need to code macros to reload the page whenever you changed the SKU-- because the subform link does not necessarily change at the same time, until a reload, for example with this code example:

root_doc = ThisComponent
form_container = root_doc.DrawPage.Forms
main_form = form_container.getByIndex(0)
row_num = main_form.getRow()
main_form.reload()
main_form.absolute(row_num)

If you run that code on the on update event for the control containing the SKU, that will ensure the subform is updated.

Alternately, just update the other controls on the same form using something like the second code example in this answer.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-11-09 08:41:17 +0200

Seen: 111 times

Last updated: Nov 11 '15