Hi,
I have a code which is creating a problem:
IF Type=0 THEN
BEGIN
GVVoucherHdr.SETRANGE(GVVoucherHdr."Voucher Type","Voucher Type");
IF GVVoucherHdr.FIND('-') THEN
BEGIN
GVVoucherHdr.SETRANGE(GVVoucherHdr."Voucher No.","Voucher No.");
IF GVVoucherHdr.FIND('-') THEN
BEGIN
IF GVVoucherHdr."Account Type"=5 THEN
BEGIN
IF FORM.RUNMODAL(18,GLAcc)=ACTION::LookupOK THEN
BEGIN
"No.":=GLAcc."No.";
Description:=GLAcc.Name;
END;
END;
END;
END;
END;
If the user selects Type 0(line level) and Account Type 5(in Header level)
then the G/L Account list form will open. Type 0 is G/L Account. I wrote the code in the OnLookup of No. field. The code is not working. Can anybody help
0
Comments
1:
don't do IF Type=0... that's not very nice to read. What is much nicer to read is to specify the type explicitly
2:
Why are you nesting all of these IF statements? It looks like you're trying to find a record, so why not just set filters? There is no point in finding records more than once. Just set all the filters and THEN try to retrieve the values. By the way, if you're setting filters on a record variable, you don't have to specify the record variable again in the filter declaration. I'm not even trying to figure out what your code means, but clean it up to look something like this:
3:
What you really want to do though, is set a conditional table relation on the "No." field. Check out the Sales Line table for an example. You can specify a relationship to a different table based on the value of another field. You don't need all that code!!
RIS Plus, LLC