Change Form from ADD mode to EDIT mode

jefrey

jefrey

Active Member
Hi Listers!

I have a Fix/Inspect (W002) Form which is called from a Find/Browse (W001) form. The W002 form updates or adds a record to the database. Multiple selection on the grid of the form W001 is ON.

My problem is how can i change the mode of the form W002 from ADD to EDIT mode everytime the form adds a record? I want the record pointer to stay on the newly added record for edit purposes. Or is there a way to navigate back to the newly added record?

Any bright ideas?
 
Hi Jefrey,

[ QUOTE ]
I want the record pointer to stay on the newly added record for edit purposes.

[/ QUOTE ]

A bit strange request (at least for me). Would you please explain for us, why do you want to do this. I am just curious.

I did not test, but maybe works the following - so please try it and let us know your results. Thanks.

#1.
On the Option Panle of Form Properties turn OFF the "End Form on Add" (if it is ON at all)
#2.
Turn ON the "Do not clear after add" on the Option panel of the Edit Control Properties FOR ALL Form controls, including all primary key fields - independenty of is it hidden or visible

You have a chance, that this will solve your issue, but you have an other chance getting "Duplcate key not allowed" error on the second OK.

Good luck,

Zoltán
 
Hi Jefrey,

Here is an other solution, if previous does not work.

#1.
Extend the form Data Structure with a flag (e.g. based on EV01) with name "cOKHadBeenPressed" or "cCommitted" or "cConfirmed".
#2.
Set this DS member to 1 on the Post Button Clicked event of OK and to 0 on the Post Button Clicked event of Cancel
#3.
Create a similar variable where you call the Fix/Inspect form and variables for all primary key fields.
#4.
Clear all key field variables
#5.
Call your FI form, and map "cOKHadBeenPressed" variable as output, and map all key field variable as Input/Output.
#6.
Create a loop:

While cOKHadBeenPressed is equal to "1"
- Call your FI form again as you called before the loop
Endwhile

#7.
On the Option Panle of Fix/Inspect Form Properties this time turn ON the "End Form on Add" option.

I suppose, this should work. Please notify us about your results. Thanks.

Regards,

Zoltán
 
Maybe I don't understand the problem, but what if you had two form interconnects in the Button Is Clicked event. The first call would open the form in Add Mode (not sure why if it is being called from a grid), then the second time the call would find the record and come up in update mode........????

If repeat for grid is set, then it would call them all twice, or you could send a parameter back in the form interconnect that the calling form could use with an if statement to only call the function the second time if the first time was in add mode....


Ben again,
 
Ben,

Just to clear things up...
I'll set an easy example to support my first post and explain why i would like the form to stay open on update mode after adding new record.

Main or entrance form is Find/Browse (W001) form.
1. Table in business view is F0101 (Address book).
2. Grid is set to Select multiple rows.

Called form from W001 is a Fix/Inspect (W002) from.
1. Table in business view is a custom table which adds records based on the selected rows from W001. F55001 consist of AN8,.... with AN8 as the primary key.

2. Based on the selected rows from W001, if AN8 exist in table F55001, the form is in update mode (no problem with this...) and when it doesn't exist, the form is in add mode and adds this record to F55001 when OK is pressed but strangely, the form stays in add mode and raises a "duplicate key" error when OK button is pressed again.

The problem only shows when a mixed action (Add and Edit) is done or when i select two or more records wherein one is in Edit mode and the other is in Add mode. But if all records selected is in ADD or all is in EDIT, there is no problem and the form stays open as i want it to be.

Zoltan,

[ QUOTE ]
#1.
On the Option Panle of Form Properties turn OFF the "End Form on Add" (if it is ON at all)
#2.
Turn ON the "Do not clear after add" on the Option panel of the Edit Control Properties FOR ALL Form controls, including all primary key fields - independenty of is it hidden or visible

You have a chance, that this will solve your issue, but you have an other chance getting "Duplcate key not allowed" error on the second OK.

[/ QUOTE ]

Yes, i tried this two but of course i had "duplicate key" error. My question is why am i NOT getting an error if ALL records selected is in ADD or ALL is in EDIT mode?

I still have to test the other solution you suggested.

Thanks for your replies.
 
Jefrey,

Almost cleared up, but a few more questions and then a suggestion (before I'm cleared up though!).

Can you verify my following assumptions?
1) You have 'Repeat for grid' checked on the Button Clicked event.
2) You are seeing the key fields populate in the Form Control fields (both in Add and Update Modes).

and questions.
A) Do you have 'End Form on Add' checked?
B) Can you tell when it is in Add mode (key fields are enabled) and Update mode (key fields are disabled)? This one may give good information - like "it is populating a key for a record that already exists, but is in Add Mode"....or something like that.
C) Is your form interconnect call in the Button Is Clicked or Post Button Clicked event?

In any case, I would still like to solve the problem but a solution (without finding the problem) may be to insert the records ahead of time before performing the Form Interconnect thereby always coming up in Update mode.....

Again, I would be real interested in the field status (enabled/disabled) for each call - so if you need to temporarily disable code to determine this, give it a try.

Also, just to make sure, the called form doesn't have a joined business view does it? Because that would not work, if between the two tables, one was update and one was add.....

Ben again,
 
Ben,
Thanks for your immediate reply. To answer your questions...

[ QUOTE ]

1) You have 'Repeat for grid' checked on the Button Clicked event.


[/ QUOTE ]
I don't have to enable this because i have enabled the 'Modeless' in Form interconnect (from W001 to W002)

[ QUOTE ]

2) You are seeing the key fields populate in the Form Control fields (both in Add and Update Modes).


[/ QUOTE ]
YES In update mode. but in add mode, i have to assign the key fields.

[ QUOTE ]

A) Do you have 'End Form on Add' checked?


[/ QUOTE ]
No because i have a modeless form and i want to be able to use the previous and next buttons.

[ QUOTE ]

B) Can you tell when it is in Add mode (key fields are enabled) and Update mode (key fields are disabled)? This one may give good information - like "it is populating a key for a record that already exists, but is in Add Mode"....or something like that.


[/ QUOTE ]
Yes. Controls behaves correclty in add and update mode. but i have set the key fields to disabled because the program will aitomatically assign values to these fields.

[ QUOTE ]

C) Is your form interconnect call in the Button Is Clicked or Post Button Clicked event?


[/ QUOTE ]
Button Is Clicked.

[ QUOTE ]

may be to insert the records ahead of time before performing the Form Interconnect thereby always coming up in Update mode.....


[/ QUOTE ]
I thought of this before but what if the user does not want to continue to add the record, so i still have to delete the "temporary" inserted record. The sense of 'ADD' and 'UPDATE' will not serve it's purpose...

Note: I am using the 'Set Save Behavior On OK' function placed in Pos Button Clicked event on OK button and Post Dialog is Initialized but it doesn't perform it's function (if i am using it right).
 
Just an FYI...

Oracle told me that 'Set Save Behavior on OK' is not really supported on Fix/Inspect forms but instead 'Set Save Behavior on OK' is usually used for PowerForms/Subforms because Development introduced this System Function when PowerForms/SubForms were introduced.

So oracle suggested a Table I/O operations for my ADD and UPDATE actions.

Cheers!
 
Back
Top