Here's my scenario:
I have a a main table, Projects, with a o2m relationship to a second table Changes. This second table is quite wide so I would like to be able to segment the information across several subforms on different tabs.
I've created a main form, the tabs and the subforms on each tab and the presentation is fine. The problem comes when I create a new record. On the first tab (containing subform1), I create a new record and fill in some values. When I click on the second tab (subform2), the new record is not there. My question is how can I keep the different subforms all in sync?
I've tried to do a Requery of subform 2 using the OnClick event on the second tab but to no avail. I could be just doing that incorrectly.
Any ideas please?
Thanks,
Jon C
Related
I have several controls on this form in addition to a tab control with 3 separate pages. I want the subform(s) within each page to requery when a value is selected on the page above.
So for the purposes of explaining this..
I have an event On_Click() on a field called Address_ID. It's meant to take tha value of that ID in addition to two other IDs, Cust_ID and Location_ID, and requery the subform Order_Sub within the Orders page.
I've named the tab control pretty blandly, just tabCtl.
So far I've tried every way imaginable to reference the subform, but to no avail.
Forms!Record_Details!Orders!Orders_Sub.Requery
That doesn't work, but I assume that it should. What gives?
Steve
You do not need to reference the tab control in your code. Just reference and requery the subform itself
Forms.Record_Details.Form.Orders_Sub.Requery
I have to create a database for a one off work project and everyone has decided to use access as it is already installed on every machine. Now I'm new to access and new to databases in general so this has been a bit of a struggle. Still I'm getting there and have managed to make all the tables, set up relationships between them and create basically all the forms, but seem to have fallen at the last hurdle.
We have lots of different sites, each of which has lots of different rooms. What I am struggling with is the form for rooms. This is loaded from the site form. So site A will bring up a form with all the rooms in site A. The form can be loaded in read only, modify, or new record modes.
The problem is with the navigation buttons at the bottom. If you click new record using the navigation button then access creates a new record, but it loses the FK reference to the previous site. I have put a 'sort of' fix on this by making the FK on the form a combobox, so it can be corrected, but there are 40 sites so it isn't very elegant and isn't the behaviour anyone would expect.
To try and get around it I decided to try and build my own version of the access navigation controls, and eventually (with a lot of help from previous questions on stackoverflow) I succeeded and at the bottom of the form you can go to the first record, previous record, next record, last record, add a new record (keeping the FK reference) and even search through the loaded records in the recordset.
However all that becomes useless the moment I switch off the navigation controls. As soon as I set that to off for whatever reason access only loads the first record in the record set. So if site A has 10 rooms you only see room 1, and the controls I made (which work perfectly with navigation controls on) stop working, and furthermore the textbox I set up to mimic the '1 of 10' record number indicator changes to '1 of 1' making it clear that none of the other records are accessible.
This is really frustrating as it means I can only use my custom navigation controls by keeping Access's turned on. I don't want the access one turned on as it creates problems every time a new record is created.
So, after that long introduction, my question is: Why is access only loading the first record with navigation controls off, is there a way to stop this happening, and if not, can I just disable the new record bit of the navigation control?
Any help here would be greatly appreciated. I am sure it is a very simple thing, but googling has turned up nothing, and actually from what I have read I'm not even sure disabling navigation controls normally does this which makes the whole thing all the more depressing as this is literally the only form I don't want them on.
Thanks,
Dean
If your only reason to add your own navigation controls was that you couldn't have the FK in you rooms form filled, I would keep the access navigation controls and set the FK in the Form_BeforeInsert() trigger of your rooms forms with something like this:
Private Sub Form_BeforeInsert(Cancel As Integer)
Me!FK = forms!Sites!PK
End Sub
If you would like to keep your own navigation controls, it would be helpful, to see your code to be able to answer your question.
I created an Organization form in Access 2007 that could be used to display any record in the Organization table by clicking the navigation buttons that appear at the bottom of the form when it is in "Form View". Next, I created a subform within the Organization form to display records from another table that have a foreign key from the Organization table.
Now the "Default View" property of the Organization form has been automatically set to "Single Form" and when I try to set it to "Continuous Forms" I get the following message:
You can't view a form as a continuous form if it contains a subform, an ActiveX control, or a bound chart.
Set the DefaultView property of the form to Single Form, Datasheet,
PivotTable, or PivotChart.
Furthermore, I am unable to use the form to view any records other than the first record in the Organization table. How can display other records from the Organization table in my form using record IDs?
While investigating this problem, I discovered that Microsoft's own Northwind Traders Sample Database contains at least one form with subforms that exhibited the behavior I wanted, even in the "Single Form" view. This suggested that the subform was not the cause of the problem.
In trying to reproduce the affect accomplished in the sample database, I recreated my form and re-added elements too it one-by-one, testing the navigation at each step. I was able to view different records via the "Form View" navigation button until I added controls from a table other than Organization that weren't contained within a subform.
So there you have it; switching between a form's source records via the navigation controls in "Form View" does not work when the master form contains records from more than one table.
I'm scratching my head whether this idea is worth exploring:
I'd like to use a tab control to filter a subform field by the value of the tab control page. There are about 5 different values for that field, so it would be neat to have 5 tabs where you click on the tab and see the list of just those matching records.
I'm a bit of an Access 2007 neophyte (haven't designed a DB with Access in years), so these are the problems that need to be solved with this approach.
Is it possible to have the same subform show on every Tab control page?
What's the most efficient way to link the value of the tab to the subform query?
I realize the brain-dead way to do this is simply create a separate subform for each page, but this seems rather inefficient. Or is it?
If you're filtering the same data, you don't need five copies of the subform, you just need to trigger a change of the Recordsource of the subform or apply a filter to it.
There are two approaches I'd consider:
use a tab, but use it just as a tab strip, with the subform not embedded on any page of the form, but below it. In the tab's OnChange event, filter the subform appropriately.
use an option group with toggle buttons and in the AfterUpdate event, filter the subform. This will look just like the tab control with the Style property set to Buttons.
I have created a very simple wpf app with mvvm light.
I have rows in a list view, these are templated representations of Book objects.
I can click a row, then click an edit button, this button loads a new window and sends the new window the book to edit (using mvvm-light's Messenger).
The issue I have is when I edit the record in my new window the data on the main form is updated. The text boxes are bound to the object received via the Messenger.
I know this is because I have essentially passed a reference to the same Book object around the place, therefore I update in one place.. and voilĂ it updates on the main page too.
What I would like to know is.. is there a standard way/method/concept to achieve what I am trying to do? i.e. create an "edit" page/screen with the option of discarding the edits?
thanks.
Could you make your entity implement ICloneable and create a clone for editing?