| View previous topic :: View next topic |
| Author |
Message |
Suthern General User


Joined: 21 Nov 2005 Posts: 13
|
Posted: Tue Jan 24, 2006 5:17 pm Post subject: Auto-insert value of Master/slave in subform |
|
|
Here is a wish:
When you have a subform and are adding records to it, the default value for the slave linked field should be automatically filled in with the current value of the filter (I'm assuming it internally does a filter).
There is NO reason that I can think of to not have it this way. I'm positive that access does it this way. This could possibly conflict if the linked field was a Primary Key.
But hey, if its a Primary Key, why is this field linked in a subform (As there could only be one record, can't add more than one record with the same Primary Key). In the case that this was the Primary Key, simply return to the old behavior and don't put anything in.
What do you guys think?
-Suthern |
|
| Back to top |
|
 |
Suthern General User


Joined: 21 Nov 2005 Posts: 13
|
Posted: Wed Jan 25, 2006 8:55 am Post subject: ahhh |
|
|
I just looked at a tutorial for linking subforms in OOo 1.4, and it seems that this feature was already working.
Did we loose this feature somewhere along the way?
-Suthern |
|
| Back to top |
|
 |
DrewJensen Super User


Joined: 06 Jul 2005 Posts: 2616 Location: Cumberland, MD
|
Posted: Wed Jan 25, 2006 11:03 am Post subject: Re: Auto-insert value of Master/slave in subform |
|
|
| Suthern wrote: | Here is a wish:
When you have a subform and are adding records to it, the default value for the slave linked field should be automatically filled in with the current value of the filter (I'm assuming it internally does a filter). |
That is exactly how it does work. Actually there was an open issue with having a compound key in the master table, but it has been marked as fixed and will be part of the 2.0.2 release. In the case of single column PK's however it works just fine now.
| Quote: | There is NO reason that I can think of to not have it this way. I'm positive that access does it this way. This could possibly conflict if the linked field was a Primary Key.
But hey, if its a Primary Key, why is this field linked in a subform (As there could only be one record, can't add more than one record with the same Primary Key). In the case that this was the Primary Key, simply return to the old behavior and don't put anything in.
What do you guys think?
-Suthern |
Usually you are talking about a primary key fied in the Master and a Foreign key field in the Linked Sub form. It would make no sense, as you say, to have it reversed. I am afraid I don't quite understand your point. _________________ Blog - http://baseanswers.spaces.live.com/ |
|
| Back to top |
|
 |
Suthern General User


Joined: 21 Nov 2005 Posts: 13
|
Posted: Wed Jan 25, 2006 11:36 am Post subject: Pardon me |
|
|
So it does work? Hmm... <goes off to test>
I made a small sample database, and what do you know, it works fine!
(Both with a automatic subform and a manually linked subform)
Now why dosen't it work in my MySQL database? <Mumble mumble mumble>
Hmm, my slave table has a compund key, part of which is the linked field.
The Master table does NOT have a compound key. <sigh>
How odd. I'll do some more testing...
Thanks Drew! (BTW: do you get paid for all the time you spend on this forum? You're awsome!)
-Suthern |
|
| Back to top |
|
 |
paolOOo General User


Joined: 30 Jan 2006 Posts: 23 Location: Italy (near Milan)
|
Posted: Mon Jan 30, 2006 5:46 am Post subject: Re: Auto-insert value of Master/slave in subform |
|
|
| Suthern wrote: | Here is a wish:
When you have a subform and are adding records to it, the default value for the slave linked field should be automatically filled in with the current value of the filter.
-Suthern |
I have the same problem of Suthern, I'm connetting with a MySQL db but the subform doesn't give the linked value automaticly.
Can anybody help me.
Thanks in advance
Paolo |
|
| Back to top |
|
 |
Suthern General User


Joined: 21 Nov 2005 Posts: 13
|
Posted: Mon Jan 30, 2006 8:27 pm Post subject: testing |
|
|
Hmm, Try creating a small test database with two tables. Link the two tables (Outside of OOo) with a simple one-to-many relationship. Build a form within OOo and a subform that is linked to the master form. Test.
I'll do the same when I get a chance.
-Suthern |
|
| Back to top |
|
 |
paolOOo General User


Joined: 30 Jan 2006 Posts: 23 Location: Italy (near Milan)
|
Posted: Mon Jan 30, 2006 11:20 pm Post subject: Re: testing |
|
|
| Suthern wrote: | Hmm, Try creating a small test database with two tables. Link the two tables (Outside of OOo) with a simple one-to-many relationship. Build a form within OOo and a subform that is linked to the master form. Test.
-Suthern |
Hi Suthern, thanks for the interest.
For a simple one-to -many relationship do you intend a foreign key in the slave form connected to the master one? If so, I've already tryed it withour any result.
I think : If OOo doesn't think about but forward the information to the mysql db, then (maybe) there's an SQL command that could have been set up inside it to solve the issue.
Anyway, I'll never give up until I find a solution,
Thanks again
Paolo _________________ Non ci sto capendo un ca##o!!! |
|
| Back to top |
|
 |
paolOOo General User


Joined: 30 Jan 2006 Posts: 23 Location: Italy (near Milan)
|
Posted: Wed Feb 01, 2006 10:18 am Post subject: |
|
|
up
is there some guru that could light up my way? I'll pay a pizza
ciao
paolo _________________ Non ci sto capendo un ca##o!!! |
|
| Back to top |
|
 |
DrewJensen Super User


Joined: 06 Jul 2005 Posts: 2616 Location: Cumberland, MD
|
Posted: Wed Feb 01, 2006 10:46 am Post subject: |
|
|
I was reading this and wondering if you are not talking about this.
I have a dataabse in MySQL 5.0.18 I craete a Base form. There is a master form and a sub form. The link is correct - let's say it is
Table1( ID, Name)
Table2( ID, PersonID, Account )
Now the Main form is ID and Name from Table1 and the sub form is a grid of Table2, linked Table2.PersonID = Table1.ID. All pretty standard stuff - right.
I insert a new record in Table1 and enter some data. I save the record. The grid is blank, no entry for an insert row. That is because the sub_form does not reload itself based on the record save on table1, rather it waits for a record movement on table1. So if you step off the record on Table1 and back, now you have a new blank record in the Subform, and on my system it is poplulated with the linked value from table1.
If this is the problem you can solve it by adding a simple macro to the MainForm's On Record Action event, this macro simply calls 'SubForm.Reload'. _________________ Blog - http://baseanswers.spaces.live.com/ |
|
| Back to top |
|
 |
paolOOo General User


Joined: 30 Jan 2006 Posts: 23 Location: Italy (near Milan)
|
Posted: Wed Feb 01, 2006 2:06 pm Post subject: |
|
|
Hi Drew,
I want a one to many relationship, let me explain...for example...I have two forms:
=>[primary form] (PKname, name)
=>[secondary form] (PKorders, PKname, orders)
For each name I want to file many orders
PKname is only the foreign key in secondary form, now, if I select or insert a row in primary form I would the PKname be automaticly filled in secondary form so that I could avoid possible mistakes and cover the entire column.
thanks for the interest
Ciao
Paolo _________________ Non ci sto capendo un ca##o!!! |
|
| Back to top |
|
 |
DrewJensen Super User


Joined: 06 Jul 2005 Posts: 2616 Location: Cumberland, MD
|
Posted: Wed Feb 01, 2006 2:26 pm Post subject: |
|
|
right, well that is just what I was trying to show.
On my machine WinXP, OO2.0.1, MySQL 5.0.18 and JDBC 3.1.12 this works just the way you describe you want it. The only issue being that you must reload the sub form after inserting a new record in the master form. If that is not happening if you just brows to a person record and then starting to enter orders, that works completely, for me.
If that is not working for you, then perhaps your installation is different. Or perhaps the Master / Sub form is not linked properly. _________________ Blog - http://baseanswers.spaces.live.com/ |
|
| Back to top |
|
 |
paolOOo General User


Joined: 30 Jan 2006 Posts: 23 Location: Italy (near Milan)
|
Posted: Thu Feb 02, 2006 6:21 am Post subject: |
|
|
| DrewJensen wrote: | right, well that is just what I was trying to show.
On my machine WinXP, OO2.0.1, MySQL 5.0.18 and JDBC 3.1.12 this works just the way you describe you want it. The only issue being that you must reload the sub form after inserting a new record in the master form. If that is not happening if you just brows to a person record and then starting to enter orders, that works completely, for me.
If that is not working for you, then perhaps your installation is different. Or perhaps the Master / Sub form is not linked properly. |
mmm...this doesn't happen on my pc (I have your same configuration), when I try to insert a new row on secondary form I have always to insert manually the foreign key, instead of the "0" given by default.
I'll try some other test this evening
thanks
Paolo _________________ Non ci sto capendo un ca##o!!! |
|
| Back to top |
|
 |
paolOOo General User


Joined: 30 Jan 2006 Posts: 23 Location: Italy (near Milan)
|
Posted: Wed Feb 08, 2006 8:26 am Post subject: |
|
|
Sorry, I would bother noboby but I've tried with SqLite instead of MySQL and the above problem disappeared (could it be a bug of MySQL?).
I would work with it now but I don't know the reliability of SqLite, any feed-back from someone experienced would be very appreciated.
Thanks in advance
Paolo _________________ Non ci sto capendo un ca##o!!! |
|
| Back to top |
|
 |
StefanR Newbie

Joined: 12 Feb 2006 Posts: 3
|
|
| Back to top |
|
 |
cbeleites Newbie

Joined: 14 Feb 2006 Posts: 1
|
Posted: Thu Feb 16, 2006 1:48 am Post subject: Problem INSERTing in subform |
|
|
Hello,
I think I have a related problem. But I'm new to OObase - so forgive me stupid questions. I didn't quite understand the information about OO Macros I found.
Anyways: my problem insertig rows in a subform
I have a postgresql 8.0 database storing sample information running on
SuSE Linux 9.3.
Openoffice 2.0
I connect to the database via JDBC.
I created a form displaying the sample information with a subform with all remarks for that sample. Normal users are allowed to insert remarks, but not to change sample information.
The remarks are in a table with the sample-id (the foreign key linking to the sample table), user id, date and the remark itself. All fields have not null constraints, date and user id have defaults in the database. So I just need to give the text and sample id to insert a remark. Using the table, this works just fine.
In my subform I'd like not to allow entering date and user id, just the text (but for the moment I allowed it).
If I do enter user id and name, everything is OK. If I just enter the text, OO gives an error message that the user id can't be left blank. The database server does not log any error, so I guess base doesn't even submit the insert.
The question is, of course, what happens.
I basically have 2 ideas how to deal with the problem. First, if I'm able to catch the event, I should be able to send the INSERT to the database myself.
Lots of questions:
I get the event object. Where can I find if / what further parameters are sent to an event handling macro?
But I couldn't find out how to get the new row?
How can I consume the event so that base does not try to send it again.
2nd approach: I added a button "add remark". The remark text is read by an Input Dialog. So far, everything is OK.
But I didn't succeed in getting the sample id - I got some value from a control with the name, but it was 1 (instead of 9999 for my test case).
I got that xray tool - but the problem is, that if I have an error with that button's macro, I don't get 1 error message but ca. 20, and 20 Input Dialogs and 20 xray windows....
I got completely lost within that event object's hierarchy
Thanks a lot in advance,
Claudia
EDIT: I found out how to read out my subform
For the 20 errors I guess that I try to use the wrong event. I used "Vor der Datensatzaktion" (before row action ? - where can I look up the translations?). But then, which one is the right event for me?
still very confused... |
|
| Back to top |
|
 |
|