I am busy developing an MS Access 2007 application that requires the use of subforms with quite a complex user interface. I am aware on how to create a parent form and link to a subform so that it shows data relating to the parent form record, but my question is this:
If I have multiple nested subforms (say 3 or 4 levels down), can I somehow link a subform sitting on the 4th level with the record of the parent form on the 1st level? What I mean by nested subforms is having a form pasted inside a form, pasted inside another form, etc.
The subform that I wish to link with the parent form is currently using a query as its source object and the reason for using nested subform is purely for the aesthetics of the user interface.
Is there a simple way to go about this? Or perhaps using VBA?
One thing that many people don't realize is that the LinkChild/LinkMaster fields can actually be any valid expression. So, you could have subForm1's LinkChild/LinkMaster properties be:
LinkMaster CustomerID
LinkChild CustomerID
Then subForm2 could have this:
LinkMaster subForm1.Form!InvoiceID
LinkChild InvoiceID
...and so forth. I can't imagine going much deeper than that, but it's possible.
You might also consider if a cascading datasheet form might do the trick, using subdatasheets. You can even have a datasheet display a non-datasheet form as its subdatasheet (something I disconvered entirely accidentally when I switched a a parent form having a subform into datasheet view -- the subform remained displayed in form view). With subdatasheets, you don't have any issues with number of forms, or the limitation on embedding continuous forms.
If this is purely for aesthetic reasons (it looks pretty to you or someone else), rather than functional reasons, why not just use a rectangle, with a "Sunken" Special Effect?
Related
I have a Search form where you can input the criteria the user will be searching for. Then when I click the Search button, the query results will show in a separate form. What I want to happen is, show the the query results in the Search form. Does anyone know what I should do (step by step) and the code for it? Thanks!
You can use Allen Browne's Search criteria form example as the basis for your search form. He provides a sample database in Access 2000 format and also a page which displays the code behind the form.
Edit: You wanted your query results presented as a datasheet in the same form. AFAIK, there is no way to display your search control on a form in datasheet view. If a continuous form is acceptable, Mr. Browne's example should be easier for you to adapt. But if you must have the query results in datasheet view, you can add a subform (with its Default View property set to Datasheet) to the search form. However, that approach will require you to apply the filter to the subform rather than the main form.
If you really need a datasheet, you could embed it as a subform in an unbound form, and then put summary fields in the footer of the parent form. This would preserve the user's ability to take advantage of the features of datasheets (as opposed to the continuous form in the example from Allen Browne).
I have an Access 2010 database set up with using the native Navigation Form interface feature.
Using this very helpful table, I've been able to use vba on multiple ocassions to reference forms throughout my database. However I seem to be having difficulty in this one instance.
On the Navigation form I have a number of main tabs. Clicking on one of the main tabs brings up a number of sub-tabs that have various forms attached to them.
On one of these sub-tabs, I have a main form (main) attached to it. There is a subform (subform1) within that main form containing a control text box (control1). Within subform1 there is another form (subform2) containing an unbound text box (control2) displaying a value that is calculated using a TempVar.
I want to use the AfterUpdate event on control1 to requery subform2 in order to update the calculation in control2, or simply requery control2.
Using Refresh and/or Requery on the AfterUpdate event for control1 does not do anything to control2.
Currently I have a button on subform2 that users can click which refreshes the form and updates the value in control2. The user can also hit F5 and refresh all the forms with the same result.
My goal is to take away the manual aspect and have the AfterUpdate event for control1 to update control2.
Any help would be much appreciated as I haven't been able to find anything online that works and I've been kicking tires at the problem for over a month now.
**** UPDATE **** I did not correctly describe the layout of my forms. subform1 and subform2 are actually both nested under main. subform2 is NOT nested under subform1 as I originally described above.
Wow. Now I feel like an idiot. Tackling my problem again with the update I provided above allowed me to solve it.
All I needed to do was requery subform2 by referencing it this way:
[Forms]![HOME]![NavigationSubform].[Form]![subform2].[Form].Requery
Where "HOME" is the name of my Navigation Form.
For anyone with the same issue that hasn't renamed their Navigation Form I believe the syntax would be:
[Forms]![Navigation Form]![NavigationSubform].[Form]![subform2].[Form].Requery
Thank you to #Erik von Asmuth and #June7 for your patience and help.
If you create a form on a table that has 1-M relationship with another table, MS-Access creates the form containing the fields of the "1" side as text boxe, etc. and for the M-Side, a tabular structure is created.
What is the name of the control representing the tabular structure? (it is some kind of a list but it is not like the list you select from the tool box!). This control does not have a click event. Why? It only has ON ENTER and ON LEAVE events, so how to capture the current row?
It is a form within the main form AKA sub-form. Although it appears to be a grid-view (Access call it datasheet view), it isn't. Therefore it does not have row based events. However, the sub-form has all the events like a normal form would.
There are few limitations in this "dataSheetView", no other controls are visible except text boxes. If you need a button, you must have a textbox with click events. Ideally place the textbox as first/last column so you have your action buttons.
Access also has a "ContinuousFormView" which can be decorated like a gridview with all custom controls. Again, they are forms and do not have row based events. Only control based or form based.
The object next to the question mark is a Subform/Subreport Container Control. As its name implies, it is a container that holds other objects which can be a table, query, form, or report. This control is also available for selection from the 'toolbox'.
Best to give the container control a name different from the object it holds, like ctrDocuments.
What do you mean by 'capture' the current row? A row is not referenced, fields and controls are referenced. Several ways to approach referencing fields and controls (if a form or report) of the dependent object. How depends on where you want to run the code. In a query? In the main form events? In the subform events? For example code in Click event of a button on the main form could be like:
strDoc = Me.ctrDocuments.DocPK
I'm creating an Access database for data entry, so I put together the form shown in the image below. It works great besides one problems I'm having that I can't seem to nail down.
I want to create a form that navigates by hiding and un-hiding subforms when clicking the buttons in the top bar. The subforms themselves are linked directly to the table (not a form, but the table itself). I did this in order to have an easy way to enter multiple entries in an excel like fashion that the users are familiar with. Entering the data works fine. Closing the form and re-opening it however causes the subform to show each individual record and the record navigations must be used to cycle through each one.
The intention was for the records be shown in the same fashion as if I just opened the table. Is there any viable way to accomplish this?
Does microsft office access have this function when i select the row from the subform,
the selected data from EmpName, ComputerName & ProductName will automatically fill into my 2 textbox at the top right and the product Name will be another combobox to select product.
Another thing is, Is it possible to do CRUD upon selection in subform?
what kind of tag should i goggle for to answer my question? I tried a lot of different tags aldy but none answers my question.
The short answer is yes. ;) You can do all those things. I well remember the day I realized that I could do anything in MS Access. (now be kind this was the first experience I had in programming)
You can reference Parent controls from subforms with this convention Me.Parent.control
For example if the Parent form has a text box named txtEmployeeId then on the Click event of a text box in the sub form you could have this code.
Me.Parent.txtEmployeeID = Me.txtEmployeeID
You can quickly extend this code to do whatever you need ie.
Me.Parent.txtComputerName = Me.ComputerName
Me.Parent.cboProductName = Me.ProductName
CRUD is a statement used in web development which seems to be where you are coming from. Access is CRUD in many ways (unless you start getting complicated) In the example above, once you navigate off the parent record with the record selector or close the form, the record is saved without any code being written. Once you start playing around with unbound controls then it becomes necessary to write code to save your work.