Show form in dialog question

I’ve have successfully created four related records and now want each of them to appear as an individual showformindialog, starting with the first one. If I understand it correctly, it will be the same dialog box with just different information.

When one is closed, does the next one appear automatically or does something have to be done and can it be prevented from closing without having entered key information.

TIA

Michael, I don’t really understand the dialog bit of your question. What you want to archieve/do. Can you explain a little more?

The other one is more simple.

Create a form or global variable ‘datachanged’ at the onShowEvent and set it to false.
Now check each field with the onDataChange event by attaching a method where you set that variable to true.
Now you create a method attached to the onHide event of the dialog form where you say if (!datachanged) return true. This prevents the dialog from closing until you entered/changed data…

REMARK: don’t forget to enable your debugger before doing so. It would hang your developer when you don’t and made a mistake…

IT2BE:
Michael, I don’t really understand the dialog bit of your question. What you want to archieve/do. Can you explain a little more?

I am working on a reservation system for hotels. There is a master record for the reservation itself and then individual (related) records for each room in which the user will need to enter the guest name, #adults, #children, etc.

If there are, for example, 3 rooms for a reservation, then after those individual records have been created, then I want each of them to show up in a dialog box so that the details can be entered. Then when the Submit button is pressed, it runs another method to create a record for each night and brings up the next room (in the dialog box) for completion. Hopefully this makes sense. TIA.[/quote]

So, what you want to do is, after creating those related record start a method where you do a loop:

for (var i = 0 : i < foundset.getMaxRecordIndex() : i++)
{
foundset.recordIndex = i;
form.name.loadRecords(blabla)
application.showFormInDialog(form.name, blabla);
}

You would create the other related records via a method in the dialog. Make sure to do the loadRecords where you would load the correct record (relation) and make the dialog based on the same table.

That should do the trick.

I apologise for my short notes but I have to leave but wanted to answer this one before leaving. Hope this makes sense…

Makes perfect sense! Thanks a million

This is all starting to make sense however I am obviously doing something wrong. The first part of the method

forms.MasterReservation.controller.newRecord();
indate = globals.tmpArrivalDate
memberid = globals.tmpCustomerID
outdate = globals.tmpDepartureDate
var rooms = globals.tmpRoomCount
roomassignid = forms.Locations.sel_roomassign_id
locationid=globals.tmpLocationID
for (var i = 0; i<rooms;i++)
{
db_tblreservation_to_tblreservationroom.newRecord();
db_tblreservation_to_tblreservationroom.memberid=globals.tmpCustomerID;
db_tblreservation_to_tblreservationroom.reservationid=reservationid;
db_tblreservation_to_tblreservationroom.indate=indate;
db_tblreservation_to_tblreservationroom.outdate=outdate;
db_tblreservation_to_tblreservationroom.roomassignid=roomassignid;
db_tblreservation_to_tblreservationroom.locationid=locationid;
}
forms.Reservations.controller.showRecords(db_tblreservation_to_tblreservationroom);
forms.Reservations.CompleteReservation();

works fine up until the very last line

forms.Reservations.CompleteReservation();

This method does indeed open the form in a dialog but it is not showing me the foundset which had successfully been found (and displayed in a list) if the last line/new method is omitted. In fact, it looks like it is showing me a completely empty record.

for (var i = 0 ; i < foundset.getMaxRecordIndex() ; i++)
{
foundset.recordIndex = i;
controller.loadRecords(foundset)
application.showFormInDialog(forms.RoomDetails, 100, 80, 650, 380, “Reservation Details”, false, false, false);
}

It is obviously something to do with

loadRecords(foundset)

but I can’t see it. Help :? TIA

for (var i = 0 ; i < foundset.getMaxRecordIndex() ; i++) 
{ 
foundset.recordIndex = i; 
controller.loadRecords(foundset) 
application.showFormInDialog(forms.RoomDetails, 100, 80, 650, 380, "Reservation Details", false, false, false); 
}

First What is foundset? Is it the controller? (did you make that javascrip variable??)

second i must start from 1 and you have to do it until the maxrecordindex:

var i=1;i<=foundset.getMaxRecordIndex();i++

then you set in a loop constantly the foundset?? But that foundset is already there.. (and looking at youre controller.loadRecords(foundset))
youre foundset seems the foundset itself… and not a controller.

What is RoomDetails for a form? does it have the same table as forms.Reservations???

because you are showing form.RoomDetails in a loop but what kind of data should it show???

if i have to guess what you want to do then this is i think the loop you want:

for(var i=1;i<=controller.getMaxRecordIndex();i++)
{
controller.recordIndex = i;
forms.RoomDetails.loadRecords(db_tblreservation_to_tblreservationroom)
application.showFormInDialog(forms.RoomDetails, 100, 80, 650, 380, “Reservation Details”, false, false, false);
}

then the relation db_tblreservation_to_tblreservationroom is a bit of a gues..

What is RoomDetails for a form? does it have the same table as forms.Reservations???

Yes, it does. Let me try and explain this a little better. The primary table tblReservation has 4 fields we are concerned with, the ReservationID, inDate, OutDate & numberRooms (from 1 - 4). The method then creates a related record (intblReservationRoom) for every room and it is these related records that I am trying to get to pop up as individual records using showForminDialog

because you are showing form.RoomDetails in a loop but what kind of data should it show???

It shows the ReservationID (which is what the relationship is based on and which allows for the creation of related records from tblReservation to tblReservationRoom. The method:

forms.MasterReservation.controller.newRecord();
indate = globals.tmpArrivalDate
memberid = globals.tmpCustomerID
outdate = globals.tmpDepartureDate
var rooms = globals.tmpRoomCount
roomassignid = forms.Locations.sel_roomassign_id
locationid=globals.tmpLocationID
for (var i = 0; i<rooms;i++)
{
db_tblreservation_to_tblreservationroom.newRecord();
db_tblreservation_to_tblreservationroom.memberid=globals.tmpCustomerID;
db_tblreservation_to_tblreservationroom.reservationid=reservationid;
db_tblreservation_to_tblreservationroom.indate=indate;
db_tblreservation_to_tblreservationroom.outdate=outdate;
db_tblreservation_to_tblreservationroom.roomassignid=roomassignid;
db_tblreservation_to_tblreservationroom.locationid=locationid;
}
forms.Reservations.controller.showRecords(db_tblreservation_to_tblreservationroom);

correctly creates the related records and leaves me in a list view in tblReservationRoom.

However if I add the next segment of code:

for (var i = 1; i < controller.getMaxRecordIndex() ; i++)
{
controller.recordIndex = i;
forms.RoomDetails.controller.loadRecords(db_tblreservation_to_tblreservationroom);
application.showFormInDialog(forms.RoomDetails, 200, 80, 650, 500, “Reservation Details - Please complete!”, false, false, false);
}

it does bring up a form inside a dialog box but the form itself is blank and it will not let me get out of it. :?

i need to see an example solution of this.

where do you add the next segment of code??
(that loop that shows the dialog)

because that loop is runned in the form Reservations yes?
(what does the form reservations show that roomsdetails doesn’t or visa versa? is one just the list/table view and the other the record?

If that last loop code is on reservations which is build on the same table as roomdetails then you should do
forms.RoomDetails.controller.loadRecords(db_tblreservation_to_tblreservationroom);

but just
forms.RoomDetails.controller.loadRecords(foundset);

And that line can be out of the loop ..

forms.RoomDetails.controller.loadRecords(foundset);
for (var i = 1; i < controller.getMaxRecordIndex() ; i++)
{
controller.recordIndex = i;
application.showFormInDialog(forms.RoomDetails, 200, 80, 650, 500, “Reservation Details - Please complete!”, false, false, false);
}
because you only have to set it once and then show the dialog for every record in the foundset.

but it can give you the feeling that you can’t get out of it because you are showing it in a loop of N records..

So if you close the first one it will open it again for the next and so on and so on. (and if there are 100+ records in the main foundset…)