Wrong record selected when pushing button on form

danielbouwmeester
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);
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..."
0
Best Answer
-
Try this instead...
PurchHeader.GET("Document Type","Document No."); MESSAGE(PurchHeader."No."); // REPORT.RUNMODAL(50087, TRUE,FALSE, PurchHeader);
2
Answers
-
Try this instead...
PurchHeader.GET("Document Type","Document No."); MESSAGE(PurchHeader."No."); // REPORT.RUNMODAL(50087, TRUE,FALSE, PurchHeader);
2 -
Thanks a lot! this works fine!"Make it idiot-proof and someone will invent a better idiot..."0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions