How to make child form refresh when master is clicked? - ms-access

I have two tables, WorkItem and Status. They are related as follows: Status.WorkItemID is the foreign key mapped to the primary key WorkItem.ID. I want to set up a form so that there are datasheets for WorkItem and Status, and when a row in WorkItem is clicked, Status is refreshed with the related rows.
I tried doing this by opening the WorkItem table, and then creating a form based on it. While this did create a form where going through the WorkItem records refreshes Status, WorkItem is represented as a set of text boxes rather than a datasheet, and I can't figure out how to change those text boxes to datasheets.
I also tried dragging WorkItem and Status tables onto a blank form, and then setting the properties for the form as follows:
Record Source is set to "WorkItem"
In the Table.Status control, Link Master Fields is set to "ID" and Link Child Fields is set to "WorkItemID"
This didn't link the two forms, though; all the rows in Status are listed, and when I click from one WorkItem row to another, nothing happens in the Status datasheet.
What am I missing?

Did you open the form in Design View and set the Default View property to "Datasheet"? When you open the Properties dialog box and click on the "Format" tab, it should be the second property from the top of the list.

Related

Displaying Related Records based on Selected Value From Dropdown List

This is my data model:
.
Can anyone please explain, how I can make a Form in MS Access, which works in the following way:
There is a dropdown list from which a user selects business unit (Business_Unit_NAM).
After the selection, on the same form, the respective records are shown below, for example, Service_Request_NAM, Service_Request_Description_NAM, Phases, Subphases, Status.
A user can scroll through every of the created records and change the value in the fields.
A more detailed explanation would be extremely appreciated.
Thanks!
You can create a form with Business_Unit dropdown (unbound) and with subform based on TBL_Star_Requests. Link this subform with dropdown control using Link Master Fields and Ling Child Fields properties. That should be enough for requested functionality. If the dropdown on the main form will be unbound, Subform Field Linker will give an error, but it will work anyway if you add field names manually. You can use the Linker if you temporarily will bound the main form to TBL_Business_Units table and bound the dropdown to Business_Unit_ID field. Remove bounding when linking done.

Rearranging the tab order of fields in a sub form in data sheet view

This is an ongoing problem, and I'm hoping there is just a property that I'm missing.
Scenario: I have a form that contains subforms. The Default View property for the subforms is set to Datasheet. (The main form is set to Single Form). Due to changes in what I'm tracking, I want to include another field that wasn't part of the original record source. So, I changed the record source (a query) and added the field to the subform. The new field is added to the end of the Datasheet view by default.
Here is the problem - when I drag the column to a new location on the subform (in Form view or Layout view), it does not stay put. I have made the change using Form view and Layout view, and I've changed the Tab Index property for the field to the proper number.  The new position never stays on the first, or second, sometimes third and fourth try. I have tried saving in Form view, Layout view and Design view, but I always have to drag the column back to the new position and try to save again . This goes on until Access actually saves the change. drag, save, didn't take; drag, save, didn't take; drag...
What I'd like to know is this - how do I rearrange columns on a form that is set to "Datasheet" for the Default View property, and make it stick the first time?
Thanks for any suggestions - I must be missing something....
This is a known "limitation" of datasheets. Some want the columns fit or preset, other sticky, some either as selected by the user.
To control the order of the columns, adjust the ColumnOrder property of the displayed controls.

Hide new row on form in Access

My project has a form with tabs, each tab displaying data from a different table based on the current record (I will call the main form's record the client) selected in the main form. If there is data present in the child table associated with that client, then show the data. If there isn't, I have a text field in my form header to say there are no records, with a link to open up a form for adding data to said child table. The form header also contains column headers for my continuous forms.
Now, if on the child form, I have Allow Additions turned off, then if the child table is empty for that client, it shows no data and the form_current or form_load methods do not seem to run, which is where I had code for hiding the column headers and unhiding my "No records" status/header text box, and vice-versa if there is data in the child form. If I turn Allow Additions on, then my code runs to hide the columns and show the status text box, but when there is data available in the table it shows the "new row" at the end of my results. I do not want the new row there.
So I can either turn on Allow Additions, have my code work, and it shows an extra new row, or I can turn off Allow Additions, my code breaks, but I don't have the extra new.
I tried to do this:
If Me.NewRecord Then
Me.field1.Visible = False
End If
but this produces undesired results; it doesn't hide the new row until I select it, then it hides all fields. I know that is how it should work, its just not the result I want .

Expression in control source and default value

I am pulling my hair here.
I want to link 2 subform fields to a field in the main form.
I used Parent.MyFieldName.Column(3) for the control source of the first subform field and it is displayed fine. The Row source of my second subform field is using the first subform field as a criteria for its query.
The problem is that this combobox remains empty when I use the above code but is populated if I give the first field a constant value.
Feels like the combobox is getting filled before the retrieval of data from the first subform field.
I tried moving the above code form control source to default value but then both fields remain empty.
What am I doing wrong?
I have found the main reason why things weren't working - Subform controls load before the rest of the main form. This means that at the time my subform dropdown menu seeks the data in the other form fields they still haven't appeared and thus I am left with an empty dropdown menu.
I solved this by removing the sourceobject of the subform control and adding
Me!Subform1.SourceObject = "SubformOtpuskaneIzhMat"
In some events in the main form.

How to open a form in Access, automatically select a value in a combobox and display the detail?

A user can select a value in a combo box and the detail automatically loads into the forms fields. How can I automatically select a particular value when (or after) opening the form and get the detail to load?
I've managed to set the value of the ComboBox after opening the form, but the detail on the page doesn't change until I manually select a value in the ComboBox.
Is the subform built with code or more simply by setting the link master field to the combo and the link child field to the matched field for the bound column? For the most part, the second way is best as it does not require the After Update code for the combo to be triggered, which won't happen when the value is set via code.