Combobox governing subform possibly updating tables - forms

I have a form, the form is bound to a query which returns only one field. On that form is one combo box, bound to the field from the query, a subform object and some other unimportant stuff. The Master-Child relationship between the Form and Subform is set to that same field. The intent is that dropping down the combo box allows me to add information on the subform pertaining to that record in the combobox (it's a list of classes in a school, for context). This is done through a form and subform as I have various different tasks that need to be done for each class - the intent is to be able to select a class on the main form and then use command buttons on it to select which subform is opened depending on which task I wish to perform.
However, the Combo box appears to be trying to update a table - I'm not sure which one as the error message isn't specific:
The changes you requested to the table were not successful because
they would create duplicate values in the index, primary key or
relationship. Change the data in the field or fields that contain
duplicate data, remove the index or redefine the index to allow
duplicate values and try again
appears if I select any value other than the first one from the combo box and then click in the first text box on the subform. However, I can click in the subform with the first entry in the combo box selected and add data successfully, I've checked and it is appearing in the underlying tables.
It seems to me, as a relative novice in Access, that the combo box is attempting to update the underlying data source when it is changed, though it has no macros. I would assume there are items in the properties of the form or the combobox that prevent that from happening but I can't find them. That is just a guess as to what's happening, though, and I could be wrong.
It's possible that this is related to this question but I could be mistaken there as well. Regardless, the Form shouldn't be able to update/edit/add records but if I set Allow Edits in its properties to "No" I am unable to actually select a value from the combobox - I have set the other "Allow" properties to "No" without a problem.

If you change anything in the main form and then click on the subform then Access will try to save the data in the main form automatically. Maybe you can try to temporally exchange the combo box with a text field for testing. That should help you to clarify the problem.

Related

MSAccess Binding a Pulldown combobox to a sub-form

I have a multi-column pulldown combo box (cmb_users) that lists user names on a form (frm_myusers), the data is straight from a table called "dbo.my_users", primary key "pc_user_id", and it is the first column in the pulldown.
I then have a multi-form sub-form embedded into the parent form (frm_myusers) that contain one or more roles for each user. The data source is straight from a table called "dbo.my_users_roles" its primary key is pc_user_id. The relationship between dbo.my_users and dbo.my_users_roles is 1 to many.
The challenge I am having is When I try to bind the combobox to the sub-form I get the "cannot bind to an unbound form error"
So then I tried passing the combobox values to a query (qry_my_users_roles)behind the scenes to drive the sub-form. The criteria for the query was on pc_user_id as =[Forms]![frm_users]!cmb_users.Column(0), and I get the error below. Not sure where to go from here.
Ultimately is there a way to simply bind a pulldown to a sub-form without the need to jump through hoops passing variables to queries and refreshing? Mapping fields to query criteria can be quite cumbersome of the spelling or syntax is not absolutely perfect :(
Thanks in advance.
As the combobox is unbound, add it to the master fields:
sci_cnt_id;NameOfCombobox
and adjust the child fields as well:
sci_cnt_id;sci_own_id
Should you wish to show all records, you must maintain the field count, so use:
sci_cnt_id;sci_cnt_id

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.

Ms Access, double click listbox element to update form

I'm trying to make an improved search text field in a form in Access. I'm searching through my customer names and I've been able to implement a "search as you type" textbox linked to a listbox where the matching records show up.
Now I want to simply double click on an item in the listbox and have all the fields of the form update automatically. I am pretty sure it already exists, but I havn't been able to find it. I'd be glad to be pointed to an existing resource or anything.
Thanks for your help!
In the listbox's On Dbl Click event, click the button and choose code builder.
Then you will need to write some code to figure out which row of the listbox is selected. Use the .ItemData method of your listbox. See here
This will return the value in the bound column of your listbox, which you can use to tell the form to navigate to the record that matches that bound column value. You may want to use a DLOOKUP to find the Record ID if the listbox bound column is not the primary key. Then you navigate to the record. For that you will likely need the .FindRecord method. See here

Using a checkbox on a form to flag record for export

I have a MS Access 2010 form with a query as the record source. I want to display all records that the query returns, and give the user an option to check any number of boxes, and when finished, a) export all the checked records to MS Excel, and b) hide those records from the form the next time it is opened.
I have tried to do this with unbound checkboxes on a continuous form (dynaset recordset type), but when I check the box for one record every checkbox for every record becomes checked, not allowing me to choose which ones I want to export individually.
You can't do what you want with unbound checkboxes. Unbound controls are called that because they are not bound to an individual record. You have two main options:
Add a Yes/No field to your table
Add a yes-no field to your table. Bind the checkbox to this new field.
Use this approach if you want your other fields to be "edit-able" and you can make changes to your schema.
Use a multi-select listbox
Switch your form from continuous to single and add a multi-select listbox. Then loop through the selected items to create an IN () clause for your export query.
Use this approach if you don't want to make changes to your schema. Also, you can set the listbox to accept Shift-Click selection of many contiguous records. That may be less labor-intensive for your users.
This is possible with the clsCCRecordSelect class from Bitsqueezer's SelectRecordsV2 database! It's a must-have for selecting records in a continuous form!

Access comboxbox selection needs to change value in label control

On a form, I have a combobox, with the RowSource coming from a query (specifically, a calculated field in the query). When the user makes a selection, I want to update a label on the same form with a different column from that same query, but of course associated to the selection.
I'm fine with VBA and writing queries and whatnot, but I am not very familiar with Access forms.
By the way, I tried searching for an answer to this, but it was quite difficult because I don't know what this thing is really called that I am trying to do. A good link to a site explaining this would be perfectly fine (no need to write a bunch of stuff here if it already exists elsewhere).
In the After Update event of my combo box, cboUserID, I can set a label control, lblFoo, to the value of the second column in the selected row of the combo.
Me.lblFoo.Caption = Me.cboUserID.Column(1)
If your combo box is bound to a field in the form's record source, you may want to do that same operation from the form's On Current event also.
You can use the column property to refer to anything other than the bound column of a combo.
Rowsource: SELECT ID, SName, FName FROM Table
Me.MyCombo.Column(2)
This would return FName.
-- http://msdn.microsoft.com/en-us/library/aa224084(v=office.11).aspx
Me.MyLabel.Caption = Me.MyCombo.Column(2)