How to make such a form

Creating and using forms
Post Reply
robakicz
Posts: 2
Joined: Wed Aug 20, 2008 11:35 pm

How to make such a form

Post by robakicz »

I have two tables, first one is a table that consists a list of my customers, with all of their data. And in the second table are orders from those.

I'm asking you to point me onto some projects, examples, similar things, that would help me to do what I'm describing below.

I need a form to input new orders from my customers, I mean existing ones. I already have a form to input new customers.

I need to have the possibility, to select a customer, from a dropdown menu I think, after which, his ID would be put into the box, which would be saved later into the orders table along with other informations to the order.

You know, in orders table only one number, the ID of the customer says, who is the one who needs the goods. But, it's not really handful, to check for a person's ID manually, and then type it by hand.

If someone have something on mind, that could help me with this, I would appreciate if you reply to this post.

Thanks in advance
Simon
User avatar
kabing
Volunteer
Posts: 680
Joined: Fri Nov 23, 2007 12:05 am
Location: Midwest, USA

Re: How to make such a form

Post by kabing »

You need a form control called a List Box. The list box will let you see the customer names, but will save the Customer ID # to the appropriate field in the Orders table.

Search for "list box" in this forum or the built-in help for information on how to set it up.

kabing
NeoOffice 2022.7 LibreOffice 24.8.4 on (Intel) Mac OS Ventura
robakicz
Posts: 2
Joined: Wed Aug 20, 2008 11:35 pm

Re: How to make such a form

Post by robakicz »

I've partially solved my problem. I found this topic http://user.services.openoffice.org/en/ ... it=listbox which helped me to make an appropriate macro.

However I'm not sure how to set up a value of the edit box correctly. Take a look at a macro I'm using

Code: Select all

sub Valuefromthelistbox
   dim oDoc,oForm,docView,ctlView,oCtl, offset, CustomerId

   oDoc=ThisComponent
   oForm=oDoc.DrawPage.forms.GetByIndex(1) !get subform with a listbox of customers in it
   oCtl=oForm.getByName("Customers")
   CustomerId = oCtl.ValueItemList( oCtl.SelectedItems(0) ) ! here we have a cutomer id :)
   
   oForm = oDoc.DrawPage.forms.GetByIndex(0) !get a main form where client id edit box is
   oCtl = oForm.getByName("CustomerID") !this is a name of the edit box for customer id
   oCtl.Text = CustomerId ! Setting up customer id edit box
End Sub
It works partially. It changes the text in the customer id edit box, but in order to save this into database, I have to click on this box, and then click somewhere else. Otherwise, it will not save the value assigned by the macro.

E.g. I can put number '3' into customer id edit box by hand, then assign '7' using a macro. If I wouldn't click on the customer id edit box, and then somewhere else it would save '3', not '7', to the database.

Any ideas to solve this ?
OOo 2.4.X on Ms Windows XP
User avatar
kabing
Volunteer
Posts: 680
Joined: Fri Nov 23, 2007 12:05 am
Location: Midwest, USA

Re: How to make such a form

Post by kabing »

I'm confused. The thread you mention concerns doing calculations. This is not what you asked about in your first post.

A listbox should work fine for the selecting the customer name but saving the customer ID number.

kabing
NeoOffice 2022.7 LibreOffice 24.8.4 on (Intel) Mac OS Ventura
Post Reply