Wrong record selected when pushing button on form

danielbouwmeesterdanielbouwmeester Member Posts: 22
Hopefully someone can help me:
The situation
I've a form with the Purchase Lines table as source. It's a simple tabular form to list my purchases goods, to see what has arrived or is due to arrive etcetera and I can sort them in different ways, so it is working fine for me. Also it displays some Purchase Header date on the side: who is the supplier etc. This info is updated when another row in the form is selected.

What I want:
I have created a report, which is based on the Purchase Header table. I want to select a row in the form and when I push a button, I want the report to get the Puchase Header No. of the selected row and to pass it as a filter to the report.

The problem is: I don't know really how to approach the problem.
I've looked up some similar examples, but the code below is the best one so far. I've inserted a line of code to show the selected row data in a textbox. If I select a record with a mouse click and push the button, the right document no. is shown in the text box. However, if I scroll the form and automatically a row is selected, a different document no. appears in the textbox. This is only happening when I'm scrolling.

Can please someone help me out?!

My code so far is:

lRecPurchaseLine.RESET;
lRecPurchaseLine.SETVIEW(Rec.GETVIEW);
lRecPurchaseLine.COPYFILTERS(Rec);
lRecPurchaseLine.SETRANGE(lRecPurchaseLine."Document No.", "Document No.");
lRecPurchaseLine.SETRANGE(lRecPurchaseLine."Buy-from Vendor No.","Buy-from Vendor No.");

PurchHeader.RESET;
PurchHeader.SETRANGE(PurchHeader."No.", lRecPurchaseLine."Document No.");
PurchHeader.SETRANGE(PurchHeader."Buy-from Vendor No.", lRecPurchaseLine."Buy-from Vendor No.");
MESSAGE(PurchHeader."No.");
// REPORT.RUNMODAL(50087, TRUE,FALSE, PurchHeader);
"Make it idiot-proof and someone will invent a better idiot..."

Best Answer

  • KishormKishorm Member Posts: 921
    Answer ✓
    Try this instead...
    PurchHeader.GET("Document Type","Document No.");
    MESSAGE(PurchHeader."No.");
    // REPORT.RUNMODAL(50087, TRUE,FALSE, PurchHeader);
    

Answers

  • KishormKishorm Member Posts: 921
    Answer ✓
    Try this instead...
    PurchHeader.GET("Document Type","Document No.");
    MESSAGE(PurchHeader."No.");
    // REPORT.RUNMODAL(50087, TRUE,FALSE, PurchHeader);
    
  • danielbouwmeesterdanielbouwmeester Member Posts: 22
    Thanks a lot! this works fine! :)
    "Make it idiot-proof and someone will invent a better idiot..."
Sign In or Register to comment.