Axapta: Programmatically switch records in a form - forms

In Dynamics AX 2009, how do you programmatically change to a different record in a form?
My form contains a treeview and a group of bound data fields. When clicking on a record in the tree (the data value for each item in the tree is the RecId of the item I'd like to edit in the form) I'd like to change the form to that record.
I've been using sysSetupForm as an example for working with a tree, but I'm having trouble isolating where the call to change records occurs in their code.
Thanks

Some example:
some_table table;
;
table = some_table:find(recid);
table_ds.findRecord(table); // it's a form datasource method

Related

Checkboxes firing on all records instead of the selected record

I'm building a form that contains a subform to list records as a datasheet. The fields on the subform are sourced from a saved query. To the subform, I added a checkbox control to serve as a record selector.
Here is the problem: When I click on the checkbox of specific record on the subform, ALL the checkboxes on all the records display a check rather than just the one I clicked. I cannot figure out what is causing this undesirable behavior.
Any insights or suggestions to fix this is much appreciated.
Your checkbox is unbound - in any continuous form or datasheet, unbound controls have the same value for all records (how else could they be unbound?).
You will have to add a "selector" column to the record source. Only bound controls can have different values for different records.
Instead of creating a field in a table (selection-data is only temporary), you can useclsCCRecordSelect-Class from SelectRecordsV2.
It binds the control to an expression (calls a function inControlSourcethat returns the value of the checkbox, stored in a collection of the class) and uses the controlsMouseDown event to change the value (as controls bound to an expression are read-only).
That makes the selection multiuser captable and avoids creating additional selection field to tables.

How to store DLookup from [Form] to Table Field in MsAccess 2013?

I have two MS Access tables: IdMhs and T_UKT. I want to automatically fill in [IdMhs].[SPP] from some criteria in [T_UKT].[UKT]. I cannot put it in query relationship, because the row cannot be edited on a form.
So I make a form and I get the number SPP (a textbox on form) automatically by using and it works fine:
=DLookUp("SPP";"T_UKT";"UKT = " & [Form].[UKT])
The problem is: the lookup value just shows on the form, and the results are not filled in the field in table ([IdMhs].[SPP]).
Any idea what an expression I should write to fill it in IdMhs table automatically?
Need macro or VBA code to save value into table. If form is bound to IdMhs table, simply like:
Me!SPP = Me.tbxSPP
The real trick is figuring out what event to put the code into. You have a control (possibly combobox) where the UKT value is selected? Use its AfterUpdate event.
Why do you need to save the SPP value and not just retrieve it in a query that joins tables?
What is nature of table relationship? Is T_UKT a lookup table? If so should be able to include it in form RecordSource and then the SPP value would be available for display in textbox and DLookup not needed. Domain aggregate functions can perform slowly on forms and reports and should be a last resort option. The same code would be used to save the value. The query join should be 'show all records from IdMhs and only those from T_UKT that match'. Set textbox bound to T_UKT SPP field as Locked Yes, TabStop No.

MS Access - Advancing through record groups

I have a form with a subform. The record source for the subform is as follows:
SELECT [firstID], [secondID], [AAA], [BBB], [CCC], [DDD]
FROM Table1
WHERE firstID = [Forms].[frm1].[txtfirstID];
The subform groups the records together on the basis of txtfirstID but when I advance through the record selector it goes through every record, as expected. I would like to know if there is a way to click through the groups rather than each record within each group. I'm open to any way of doing it. Perhaps filtering through VBA??
Thanks!
First, add a combo box to your form. Set the RecordSource for the combo box to a distinct list of groups, or, if you have a group lookup table, select * from tblGroups. Set the display field to be group name, and the value field to be group id.
Second, after an item is selected from the combo box, modify the RecordSource sql of the form (your query) so that it uses the current value of the combo box. The value of the combobox would be what your where clause should be looking for.
I think you can do two ways to solve this:
1.- If you related main form to subform by a field. In this case TxtFirstID of Main to FirstID of subform. It do all work when change main form and filter automatically on subform
2.- You can do and event OnChange form TxtFirstID on main form.
Sub TxtFirstID_Change()
Me.subfrmName.Form.RecordSource = "Select * from table1 where firstID=" & Me.TxtFirstID 'change the record source for the SubForm
me.subfrmName.Form.Requery 'Force Access to refresh the Record Source
end sub

Cannot see records in form bounded to table in Access

I have a form and it's record source is a table. I created the form separately and added the control sources to the different fields in the form and also changed it's record source. I imported values from an excel sheet into the table and when I open the form, I do not see the tabe values being displayed in the form. Any idea what I should do to see the table records in the form?
In form design mode, check the form's DataEntry property. It sounds like yours is set to Yes, which hides existing records and only allows new entries. Change it to No and you will see the existing records.
Another possibility is that a filter is active and no records match that filter.
Use a form wizard to generate a working form based on your table. Then once you can see the data being displayed in the form, customise as needed.

Inserting rows in form datasource, insert is OK, rows are not visible

Basically, I want to insert rows in the form InventJournalTransfer. I added a menuitem button that calls a class which opens a dialog where I fill a WMSLocationId, then I loop on Inventsum table to get all ItemIds with Available qty for this WMSLocationId and insert them into InventJournalTrans Table.
The code I wrote seems to be working as I have correct records inserted in my table(visible in Table browser, correct journalId, linenum itemId, qty etc...) BUT the records inserted do not appear in my form. I tried to refresh my form with or without code, but my grid's still empty.
I had a look at the class InventCountCreate that does what I want to do in a different journal type, but as I'm quite a newbie it is difficult for me to understand exactly how this class works.
Could anyone explain to me how to display my inserted rows in my form or give other leads?
The InventJournalTrans is table is inner joined to two InventDim, one related via the InventDimId field, the other via ToInventDimId.
Both fields must be filled with a valid InventDimId to an existing InventDim record for the form to show the record.
Have you tried right-clicking on your form's node in the AOT and clicking "Restore"? Perhaps your form is still using cached data.