Default Value

Discuss the database features
Post Reply
dreamquartz
Posts: 881
Joined: Mon May 30, 2011 4:02 am

Default Value

Post by dreamquartz »

Hi All,

I am trying to figure out how to get a different default value for a record in a table, when using different forms.
I have 2 forms, fPerson, and fCompany.
For fPerson I want the default TypeOfAddress be 'Residence', but for fCompany I want it to be 'Business'.

All addresses are entered in the same table, and the selection of TypeOfAddress is via a ListBox and SQL statement.

Is this at all possible?

Dream
LO 7.x, HSQLDB 2.7.x & Ubuntu 22.04 LTS.
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Default Value

Post by Villeroy »

Subforms inherit their default values from their parent form.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Default Value

Post by Villeroy »

... so the only thing you need is a calculated field in the parent form passing over the required data to a subform's new record.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
dreamquartz
Posts: 881
Joined: Mon May 30, 2011 4:02 am

Re: Default Value

Post by dreamquartz »

Both forms are stand alone.
fPerson is to enter personal data, like Name..., Address, Phohe, Email.... fPersonAddress is a subform from fPerson.
fCompany is to enter company info, like Company name, Address, Contact Person, Email..... fCompanyAddress is a subform from fCompany.

All addresses are placed in tAddress.
I have the default in the table tAddress for TypeOfAddress set to 'Residence' (Don't know how I did that anymore ;() or a Person, but that is at table level. This default does not work for a Company. There the default should be 'Business'.
LO 7.x, HSQLDB 2.7.x & Ubuntu 22.04 LTS.
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Default Value

Post by Villeroy »

dreamquartz wrote:Both forms are stand alone.
Combine them.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
UnklDonald418
Volunteer
Posts: 1544
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Default Value

Post by UnklDonald418 »

If there are only the two types of addresses a Boolean field would work for “TypeOfAddress” .
Add a Group Box Control to both fPerson and fCompany with option buttons for Residence and Business.

If you are not familiar with option buttons:
Open form document fPerson in the Edit/Design mode and add a Group Box control.
That should open the Group Element Wizard.
On the Data page of the wizard add option buttons for Business and Residence.
On the Default Selection page choose Residence.
On the Field Values page accept the default values of 1 for Business and change Residence to 0.
On the Database Field page select TypeOfAddress
On the Create Option Group page type in the name/label to appear with the group box.
Open the Properties: Option Button dialog for the Residence button
On the General tab verify that the Default status is Selected
On the Data tab verify that the Data field is “TypeOfAddress” and set Reference value (on) to 0 and Reference value (off) to 1.
Select the Business button to open the Properties: Option Button dialog
On the General tab verify that the Default status is Not Selected
On the Data tab verify that the Data field is “TypeOfAddress” and set Reference value (on) to 1 and Reference value (off) to 0.
Exit and test the form.
Remember the default value only applies to new records, so you will need to manually select the values for existing records.

Use a similar process to add option buttons to form document fBusiness.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
dreamquartz
Posts: 881
Joined: Mon May 30, 2011 4:02 am

Re: Default Value

Post by dreamquartz »

Villeroy wrote:
dreamquartz wrote:Both forms are stand alone.
Combine them.
;(. That will not work. Like your answer though.

Our Client has both companies and persons as paying clients. The person information is stored in the tPerson table. This table holds all the relevant person information.
A person can be an employee of a company or a private person.

The company information is stored in the tCompany table.

If the paying client is a company, then our Client communicates with their contact person. The company information must be entered and the person information must be entered as a contact.
If the paying client is a person, all their personal information, like dob, home address, and other relevant personal information must be stored
Both types of information are exported to their accounting software.
As a participant the relevant personal information is also exported to external databases for formal confirmation of their participation.

Thee contact person can become a participant.
In the capacity as a contact, only Surname, GivenName, title, phone number, and email address recorded.
In the capacity as a participant, all personal information, like dob, home address, and other relevant personal information is also to be stored.

There is therefore no way that these 2 forms can be combined, because of the information types to be be stored.
In fPerson, new participants can be added as an Employee to an existing (returning client) company.
In fCompany, new Addresses and related contact persons can be added. Per Address new contact persons can be added and others set InActive. Addresses can be set InActive.

The principle of 2 forms was based on one department enters Companies and Persons as paying Clients (Finance Department) and an other department enters participant information (Project participation Department).

Hopes this clarifies my dilemma a little.

Cheers,

Dream
LO 7.x, HSQLDB 2.7.x & Ubuntu 22.04 LTS.
dreamquartz
Posts: 881
Joined: Mon May 30, 2011 4:02 am

Re: Default Value

Post by dreamquartz »

UnklDonald418 wrote:If there are only the two types of addresses a Boolean field would work for “TypeOfAddress” .
Add a Group Box Control to both fPerson and fCompany with option buttons for Residence and Business.

If you are not familiar with option buttons:
Open form document fPerson in the Edit/Design mode and add a Group Box control.
That should open the Group Element Wizard.
On the Data page of the wizard add option buttons for Business and Residence.
On the Default Selection page choose Residence.
On the Field Values page accept the default values of 1 for Business and change Residence to 0.
On the Database Field page select TypeOfAddress
On the Create Option Group page type in the name/label to appear with the group box.
Open the Properties: Option Button dialog for the Residence button
On the General tab verify that the Default status is Selected
On the Data tab verify that the Data field is “TypeOfAddress” and set Reference value (on) to 0 and Reference value (off) to 1.
Select the Business button to open the Properties: Option Button dialog
On the General tab verify that the Default status is Not Selected
On the Data tab verify that the Data field is “TypeOfAddress” and set Reference value (on) to 1 and Reference value (off) to 0.
Exit and test the form.
Remember the default value only applies to new records, so you will need to manually select the values for existing records.

Use a similar process to add option buttons to form document fBusiness.
Will look into your suggestions.

Was writing comments to Villeroy.

Cheers,

Dream
LO 7.x, HSQLDB 2.7.x & Ubuntu 22.04 LTS.
Post Reply