I am looking to see if there is an easy way to rename subforms. I have a single form with about 8 forms, and 8 queries running each subform. I want to systematically rename each form and query I thought I had done this in the past though when I rename a form or query I get the error regarding the subform is missing. Obviously this is caused by the fact that I broke the link between form and subform.
Normally if this was just 1 or 2 subforms I would just remove the old ones and add the new ones back in there. Though As there are so many on this form, I would rather avoid having to do that if possible because each form also has to be arranged a specific way since this will be converted to a PDF at some point.
TL:DR I want to rename multiple subforms without having to re-add them back onto the main form (if possible)
Open the main form in Design View
Select a subform control (make sure to select the control, not the form it contains).
Open the control's property sheet and select the name of the new form from the Source Object dropdown.
You will need to perform steps 2 & 3 for each of the 8 subform controls.
If that's more effort than you want, look into the Track Name Autocorrect property in the database options. I'm not sure whether that would automagically update the subform Source Object property when you rename the form object, but it shouldn't take long to find out. Personally I mostly avoid turning on Track Name Autocorrect because it's been reported to cause odd behavior. If you use it, consider turning it on only when you need to rename a bunch of objects and turn it back off afterward.
Related
I have a form with a subform that lists current material information being entered on the main form, like a log/history view.
On the subform there is a field that specifies which skid the product was assigned. I made this field a hyperlink so that I could use the OnClick event to launch a report and be able to extract row information needed to generate the proper summary.
That works great, and I thought it was finished until I attempted to edit the skid number from within the subform.
Allowing edits in the subform is a project requirement. Editing the skid number in the hyperlinked field breaks my code. Access automatically appends #http://# to the end of whatever value I enter into the cell and updates the table with this string. That row then gets omitted from the report because I'm keying off of the skid numbers. By design, this hyperlink has no path or address, I just use it to determine which row is being clicked.
How can I prevent Access from appending the #http://# while keeping the "Is Hyperlink" property to Yes? Is there another property to set this behavior or should I use the AfterUpdate event to undo the addition, which just seems like a waste of resources?
I am running Access 2010.
There is a long and very thorough article here that I will not copy ;) It elaborately states why its a bad idea to even use the hyperlink-field and what to do to get the same result you need without a hyperlink-field.
Basically, the main point of the hyperlink-field is all that behind the scenes shenanigans you cannot do anything about - and thats not what you want as a programmer.
The Hyperlink-field internally consists of three parts: A Text-part, a Link-Part and a Tooltip-Part. And although you can access them separately, access always tries to create a link.
You can try to format the data you have in the internally used format (DisplayText#Address#SubAddress) but I think that is not what you need...
So I think you best take Philipps advice and change your field-type.
In ms access I have a form which also has a sub-form. I wanted to programmatically change the RecordsetType in the main-form to snapshot when the sub-table/sub-form has associated records in the one-to-many relationship. I wrote some vba code to do this but I was experiencing some very odd behaviour.
I then discovered that it was because when I change the RecordsetType, the form refreshes and navigates back to the first record. That then causes the On Current event and associated code to fire in both the sub-form and main-form twice. I was thinking of using DoCmd.SearchForRecord to navigate back to the original record but quickly realized that it wouldn't work because the the WHERE condition in the DoCmd.SearchForRecord gets overridden when the events fire the second time around. It all seemed so inefficient any way.
Are there any other methods to do what I am trying to do? I don't really want to set the controls in the form to 'Disabled'.
MS Access has a selection of form properties that should suit: AllowEdits, AllowDeletions and AllowAdditions. These can be set separately or together. In this case, it seems that you need AllowAddition set to Yes and AllowEdits set to No.
In ms-access 2007, i'm trying to make a form for a table. this table has foreign keys from 2 parent tables. so i thought i would make these fields a lookup. but i couldn't create a single lookup for each parent table because they are composite keys.
I decided to create a query in which for each of these parent tables and the child table with an extra field for each composite key. this works fine with a normal form using an unbound ComboBox... but the unbound ComboBox does not work in a DataSheet Subform. when i make changes to a ComboBox in the Subform code, they are applied to all the other ComboBoxes in the same column as well.
My questions:
is there a way to change the values of the individual unbound ComboBox?
is there a different control i should be using other than the ComboBox or the DataSheet Subform?
what is the normal work around for this situation?
I cannot bind the ComboBox's because the field from the query is calculated/an-expression as I said.
I ran across a form of this problem myself, so for the sake of posterity:
While generally, the advice "Don't use continuous forms/datasheets in this situtation" is the best advice...It is possible to work around this.
However, access will not let you update the value of a single control on a datasheet. What can be used instead in this case is a temporary table, which can, when used as a recordsource, become the values of those controls. You will need to repopulate the table, and requery the controls (requerying the entire form should work as well) every time the calculation needs to change, however. Furthermore, should you enable editing on the controls, you will have to write some VBA on each control to handle the update event (Before Update), and run your own query to update the source tables, not merely the temporary table. Annoying to do perhaps, but effective.
There is another possibillity, which may also work, but I haven't tried to do something quite like this myself. The rowsource of a combobox can be very complex, so it is probable that you do not need to update the comboboxes with VBA at all. The rowsource can depend on other controls (such as another combobox) using the syntax Me.Form!controlName or Forms!FormName!ControlName, which will allow you to form the composite key. Of course, you can also select from queries with a rowsource. What is more interesting is that queries can reference controls on your form, provided the form is open, and you should safely be able to modify that with VBA should you have to.
Between the two of these, you should be able to force access, kicking and screaming, to display any data you wish, even on a datasheet, and to allow the user to change that data (but only if you want it to), and using the BeforeUpdate event, drag modified data back to whatever table it came from.
Continuous forms and datasheets do not work well for editing in situations where combo boxes need to be changed conditionally. The problem is that if you use the OnCurrent event to set the Rowsource of the combo box, it will be OK for that row, but will then hide the stored values for other rows.
The solution is to never use continuous forms/datasheets for editing data when this is the case (I hardly ever use them for editing, in fact). You can create two subforms, a continuous/datasheet subform that functions as a list, and a detail subform, that displays one record. Make the list subform uneditable, and the detail subform editable. You can link the two of them by using the Link Child/Link Master property of the detail subform control, and set it to the PK of the list subform.
If your list subform is Me!List and your detail is Me!Form, and the PK field is MyID, your link properties for the detail subform would be:
Master: Me!List.Form!MyID
Child: MyID
When you move to a different record in the list form, it will be automatically loaded in the child form. Any edits to the previously displayed detail will be saved before record departure.
this has me pretty confused and I can't find the answer anywhere else so thought I'd post here to see if anyone can help!
I have a form in an Access 2007 database with a subform (sfSubform) embedded in it. The subform control's SourceObject is set to be another form (fForm). fForm's RecordSource starts out as a table.
At one point I want to change the data displayed in the subform to the result of a SQL statement, so I use
sfSubform.Form.RecordSource = strSQL.
This works fine. However, if I ouput the name of the RecordSource for fForm after making this change, it still gives the name of the table that I orginially set.
Does sfSubform.Form.RecordSource not change the source of fForm? Is it a copy of fForm that is embedded in the control?
Hope all that makes sense.
The sub-form and the form each have their own record source (or are unbound). That's the whole point, actually -- the ability to present two different data sets. Typically the two forms have related record sources and this relationship is declared using Master/Child Link, but that also is optional according to the need.
So no, changing one won't cause the other to be changed.
I have several forms linked tables via queries. The form pull data such as sales and ratios by selecting a product from the main's form's combo box.
I am however having to issues:
1- I would ultimately prefer the combo box to be a free entry; however by just entering in the box and hitting enter (not a button called “enter on a screen” which would initiate recalcs, just normal enter), while it does bring the new information in sub-forms it also changes the information in the original table. If I make the table read only that it just doesn't allow the form to work by saying that the table is read only.
2- The same Read only issue occurs when another user with read only rights tries to use the database.
I understand that ready only is functioning as intended, however I am wondering if there is way to make some functions work while disallowing the updating.
I am unfortunately learning on the go, so go easy plz.
Thank you
You need to make your combo box no linked to the underlying data, but once the data is changed, set/reset the value of the combo box. This way, if some types in a new value
A) it will not update the data whether it is updatable or not.
B) you can still have the subforms update based on this value
Private Sub Form_Current()
cmbMyDisplayOnlyComboBox = Me!WhatEverFieldHasTheValue
End Sub
Again, cmbMyDisplayOnlyComboBox Control Source is blank. Substitute the field that 'use' to be the Control Source as WhatEverFieldHasTheValue