But I am not asking about closing the current form. I m asking about how to close the already opened form.
Eg : -
I am opening "Sales Order" from "Purchase Order" form, then I am getting the Value of "No." Field in the "Sales Order" form. Then I want to close the "Sales Order" form.
Create a variable frmSalesOrderForm in the Purchase order form.
Use that to open the form and having the "No." and then to close it:
frmSalesOrderForm.CLOSE;
I hope this is what you wanted, otherwise you have give a more detailed description of what you exactly want.
Regards,Alain Krikilion No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
When you will get a fieldvalue from the Sales Order and after this close the Form, you can use this:
Variable
SalesHeader Rec 36
//....
Salesheader.setrange(YOUR Filters);
if form.runmodal(0,SalesHeader) = Action::Lookupok then
MYFieldOrVariable := SalesHeader.TheFieldThatYOUWANT;
This will open the Sales Order List (Property LookupFormID in Table 36)
When you will open an other form:
Variable
SalesHeader Record Sales Header
MyForm Form MyForm
//...
Salesheader.setrange(YOUR Filters);
clear(MyForm);
MyForm.lookupmode(true); //The Lookupbuttons must be exist
if MyForm.runmodal = action::LookupOK then
....
//....
//After LookupOK or LookupCancel the form close automatic
If you want the user to select the order - the below code could do the trick:
SalesListFrm.LOOKUPMODE(TRUE);
SalesHeader.SETRANGE("Document Type", SalesHeader."Document Type"::Order);
SalesListFrm.SETTABLEVIEW(SalesHeader);
IF SalesListFrm.RUNMODAL = ACTION::LookupOK THEN BEGIN
MESSAGE('Sales List form is already closed...');
SalesListFrm.GETRECORD(SalesHeader);
MESSAGE('%1 was chosen by the user', SalesHeader."No.");
END;
IF SalesOrderFrm.RUNMODAL = ACTION::OK THEN
BEGIN
MESSAGE('Sales Order form is going to close');
SalesOrderFrm.Close();
END;
The command RUNMODAL tells the system to stop everything it is doing until the form is closed. It will not get to the MESSAGE, because it is waiting for the user to take an action on the form. You even specify the action (that's the ACTION::OK part). This can only happen if there is an OK button on the form that you are opening.
One of the things that happens when the user clicks the OK button is that the form that holds the button closes. So writing the above code doesn't do any good, because by the time you would get to the CLOSE method, the form is already closed.
Maybe you could explain to us what you want to do and we can help you find a solution.
1. Open the Sales Order form.
2. If the Items avilability < 0 then, I will open the purchase order.
3. Get the Sales order No from the Sales order form.
4. Match that Item and have to create Purchase Order for those items.
Eg : IF the items availabilty = -6, then I have to create Purchase order for item with quantity = 6.
Comments
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
But I am not asking about closing the current form. I m asking about how to close the already opened form.
Eg : -
I am opening "Sales Order" from "Purchase Order" form, then I am getting the Value of "No." Field in the "Sales Order" form. Then I want to close the "Sales Order" form.
Use that to open the form and having the "No." and then to close it:
frmSalesOrderForm.CLOSE;
I hope this is what you wanted, otherwise you have give a more detailed description of what you exactly want.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
I have created a variable "SalesOrderFrm" in the "Purchase Order", then I tried to open "Sales Order" form by writing the below code.
IF SalesOrderFrm.RUNMODAL = ACTION::OK THEN
BEGIN
MESSAGE('Testing');
SalesOrderFrm.CLOSE;
END;
But I m getting error while compiling
Error : "You have specified unknown variable CLOSE."
Thanks
N.Sridhar
You have to create a function in the sales order form in which you put CurrForm.CLOSE;
When you want to close the form, call that function.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Regards,
N.Sridhar
I typed the followind code, the form is opening but not closing.
I m not even getting the message "'Sales Order form is going to close".
IF SalesOrderFrm.RUNMODAL = ACTION::OK THEN
BEGIN
MESSAGE('Sales Order form is going to close');
SalesOrderFrm.Close();
END;
Thanks,
N.Sridhar
Regards
SalesListFrm.LOOKUPMODE(TRUE);
SalesHeader.SETRANGE("Document Type", SalesHeader."Document Type"::Order);
SalesListFrm.SETTABLEVIEW(SalesHeader);
IF SalesListFrm.RUNMODAL = ACTION::LookupOK THEN BEGIN
MESSAGE('Sales List form is already closed...');
SalesListFrm.GETRECORD(SalesHeader);
MESSAGE('%1 was chosen by the user', SalesHeader."No.");
END;
/Frank Mortensen
One of the things that happens when the user clicks the OK button is that the form that holds the button closes. So writing the above code doesn't do any good, because by the time you would get to the CLOSE method, the form is already closed.
Maybe you could explain to us what you want to do and we can help you find a solution.
RIS Plus, LLC
Here are my task list:
1. Open the Sales Order form.
2. If the Items avilability < 0 then, I will open the purchase order.
3. Get the Sales order No from the Sales order form.
4. Match that Item and have to create Purchase Order for those items.
Eg : IF the items availabilty = -6, then I have to create Purchase order for item with quantity = 6.
N.Sridhar