Subject: RE: You should be able to figure out any additional code you need from this…
Hi Bill
Sorry about this, I dont want to become a nuissance. I added another two fields called Cuname and Cudate which are computed fields on the DialogBox form, I modified the Add button code to this:-
tbRet := @DialogBox(“Contract”; [AutoHorzFit] : [AutoVertFit]);
@If(tbRet = 0; @Return(“”); “”);
@If(“” != Cnamedb : Cinfodb : Cdate : Cuname; “”; @Return(“”));
REM;
tbNum := @If(Cname = “”; 1; @Elements(Cname) + 1);
REM;
FIELD Cname := @If(tbNum = 1; Cnamedb; Cname : Cnamedb);
FIELD Cinfo := @If(tbNum = 1; Cinfodb; Cinfo : Cinfodb);
FIELD Cdate := @If(tbNum = 1; Cdatedb; Cdate : Cdatedb);
FIELD Cuname := @If(tbNum = 1; Cunamedb; Cuname : Cunamedb);
REM;
FIELD Cnamedb := @DeleteField;
FIELD Cinfodb := @DeleteField;
FIELD Cdatedb := @DeleteField;
FIELD Cunamedb := @DeleteField;
REM;
@Command([ViewRefreshFields])
and modified the edit button to this:-
tbNum := @If(Cname = “”; @Return(@Prompt([Ok]; “No Items Found”; “You have not entered any items in the table yet (therefore, there’s nothing there to edit).”)); @Elements(Cname));
REM;
tbL1 := “0” : “1” : “2” : “3” : “4” : “5” : “6” : “7” : “8” : “9”;
tbL2 := @Subset(tbL1 *+ tbL1; -99);
tbNumList := @Subset(tbL2; tbNum);
REM;
tbChoices := tbNumList + ". " + Cname;
tbChoice := @Prompt([OkCancelList]; “Select Item”; “Please select the item you would like to update:”; @Subset(tbChoices; 1); tbChoices);
@If(tbChoice = 1; @Return(@Prompt([Ok]; “No Item Selected”; “You did not select an item. This process has been stopped.”)); “”);
REM;
tbLNum := @Member(tbChoice; tbChoices);
tbIsFirst := cname = 1;
tbIsLast := tbLNum = tbNum;
tbIsOnly := tbNum = 1;
REM;
FIELD cnamedb := @Subset(@Subset(cname; tbLNum); -1);
FIELD cinfodb := @Subset(@Subset(cinfo; tbLNum); -1);
FIELD cunamedb := @Subset(@Subset(cuname; tbLNum); -1);
FIELD cdatedb := @Subset(@Subset(cdate; tbLNum); -1);
REM;
tbRet := @DialogBox(“Contractordetails”; [AutoHorzFit] : [AutoVertFit]);
@If(tbRet = 0; @Return(“”); “”);
@If(“” != cnamedb : cinfodb: Cunamedb : cdatedb; “”; @Return(“”));
REM;
FIELD cname := @If(tbIsOnly; cnamedb; tbIsFirst; cnamedb : @Subset(cname; 1 - tbNum); tbIsLast; @Subset(cname; tbNum - 1) : cnamedb; @Subset(cname; tbLNum - 1) : cnamedb : @Subset(cname; tbLNum - tbNum));
FIELD cinfo := @If(tbIsOnly; cinfodb; tbIsFirst; cinfodb : @Subset(cinfo; 1 - tbNum); tbIsLast; @Subset(cinfo; tbNum - 1) : cinfodb; @Subset(cinfo; tbLNum - 1) : cinfodb : @Subset(cinfo; tbLNum - tbNum));
FIELD cuname := @If(tbIsOnly; cunamedb; tbIsFirst; cunamedb : @Subset(cuname; 1 - tbNum); tbIsLast; @Subset(cuname; tbNum - 1) : cunamedb; @Subset(cuname; tbLNum - 1) : cunamedb : @Subset(cuname; tbLNum - tbNum));
FIELD cdate := @If(tbIsOnly; cdatedb; tbIsFirst; cdatedb : @Subset(cdate; 1 - tbNum); tbIsLast; @Subset(cdate; tbNum - 1) : cdatedb; @Subset(cdate; tbLNum - 1) : cdatedb : @Subset(cdate; tbLNum - tbNum));
REM;
FIELD cnamedb := @DeleteField;
FIELD cinfodb := @DeleteField;
FIELD cunamedb := @DeleteField;
FIELD cdatedb := @DeleteField;
REM;
@Command([ViewRefreshFields])
I am using a different DialogueBox for the edit button, so that the Cuname and Cudate are no longer computed and pick the information from the table, also the Cuname, Cdate abd Cname are hidden so only the Cinfo is editable on the DialougeBox.
This seems to work ok, but I do get this error at time when editing one of the lines:-
ERROR: The second argument to @Subset must not be zero.
I have looked at my code but cant see anything wrong, can you shed some light on this for me. This problem only started after I added the other two fields, so it may be something I have missed out when adding the new fields.
Regards
Douglas Bell