newRecord() in a Tab Panel

Hi Folks - this one is so basic I’m a bit shy to ask it :oops: , but I’m also a little lost :? .

I have a Form With a Tab Panel with a list-form based on a relation. I have a button on the header of the list form to add a record.

Using controller.newRecord(true,true) I get a new row but no means to populate it, and an error on save (of course).

Using forms.ListForm.relation.newRecord(true,true) I get an error on click (cannot call method…)

I note that the 3.5 docs suggest I should create a ‘record based on the relation first’. How should I structure the method to add a new record to the related table and show it in the tab panel?

Appreciate feedback.

If formA is your main form, and formB your tab form, you should do:

forms.formA.tableA_to_tableB.newRecord();

The relation tableA_to_tableB should be the same relation you use to link the tab to the main form.

Thanks for that Joas - now have the new row added to the tab panels table form. But another snag I suspect is related to how I’m doing this and the structure is a little more complicated with nested links thru several tables:

FabricForm > Tabpanel_TableForm.fabric_to_inspection_remarks

Single column in Tabpanel_TableForm > Dataprovider inspection_remarks _to_remak_codes

So the dropdown uses a valuelist to show both the inspection_remark id and the actual description from remark_codes and I can use the valulist dropdown to edit (change) the row entry - so that works fine.

When the new row is added obviuosly its blank, and I can select the dropdonw and highlight an entry. Unfortunately that entry is not added to the table or entered into the empty row.

If I change the record (navigate one to another) after adding the row I get the message ‘cant save form data’ - yet the empty row is save in the record?

What have I missed to allow the valuelist to be selected and entered in the empty row? I recognise that it’s something to do with editability but because of the nesting I cant determine what?

A screenshot would be helpful here. Can you provide one?

Kahuna:
I get the message ‘cant save form data’

The reason for this should be in the logfiles…
Most common reason is there’s a value required by the database which you forgot to set.
So if you look into this specific table definition and look for the ‘allowNull’ checkboxes that are disabled I think you probably can figure out why it doesn’t want to save the form data…

Hope this helps!

mboegem:

Kahuna:
I get the message ‘cant save form data’

The reason for this should be in the logfiles…
Most common reason is there’s a value required by the database which you forgot to set.
So if you look into this specific table definition and look for the ‘allowNull’ checkboxes that are disabled I think you probably can figure out why it doesn’t want to save the form data…

Hope this helps!

Thanks Guys - Marc the column is set to NOT Allow Null, and thats the way it should be of course - we dont want null rows being added by a user.

In my VB app I would create the row but not committ it until it had data, if none added then the row would not be saved. In this environment where I need to nest the tabs and use multiple relationships, how can I create a row and have data added to it yet not save it?

There seems to be two problems here:

  1. Empty row being saved (and it is saved regardless of what the error says). Why does an empty row show in this instance?
  2. I can’t later populate (or edit) that row with the combo dropdown as I can with previously added data in that table. If the row shows, why cant it be edited / populated?

Possible Solutions:

  1. Turnoff Save before adding the row - then back on after data added and save made - if no data dont save?
  2. Seed the row with data as a default entry - so add new row should come pre-loaded?

Are any of these sensible approaches?

Hi guys - I’ve moved on since yesterdays hair pulling exercise, and have somewhat solved the challenge.

Now:

Form in tabpanel - single combobox with a valuelist.

Form ‘frmFabric’ > tabpanel>Form ‘frm_inspection_remarks’.

Valuelist> inspection_remarks_to_remark_codes.

I can add rows (with controller.newRecord) and edit rows - valuelist is showing correctly.

Now however if I try and delete a row with controller.deleteRecord the record that is deleted is actually the record used in the value list (from table remark_codes) for the extra info lookup. I think it should be deleted from inspection_remarks. The only reference to the remarks_code table is in the valuelist - so how can I delete the record from the inspection_remarks table directly? I tried the following but its not valid: forms.frm_inspection_remarks.controller.deleterecord()

Any other advice appreciated. Attchd screen grab just in case it raises a thought?

[attachment=0]Remarks.jpg[/attachment]

Does your relation “inspection_remarks_to_remark_codes” have “delete related records” checked?

Joas:
Does your relation “inspection_remarks_to_remark_codes” have “delete related records” checked?

Joas - you are a cruel cruel man - beating me up with a single line response :oops:

Yes indeed it did have that checked. Thanks a load Joas - one day this might fall into place!

Kahuna:
Joas - you are a cruel cruel man

Always happy to help. :wink: