I need to filter a subform using a value in a combobox from the mainform.The value in the combobox is string(a sentence of a line or two)This value is called "Descr" in the select query of the subform and the name of combobox in the parent form is "cboOverdueDescr".
I have put the following code in the AfterUpdate event of the combobox.
LinkChildFields="Descr"
LinkMasterFields="cboOverdueDescr"
The problem is that the subform shows no record when I select any value in the combobox.However, the subform gets filtered accordingly when I do it the same way with another combobox which displays values like "B13-1000"
Even if your combo has a column called Descr, your form does not know that, all it knows is the number of columns, however, you can use a combobox as the link master field for a subform, the filter will use the value of the bound column. Just set the link master field to the name of the combo, there is no need to use an event.
Related
In access 2010 I am trying to create a listbox in a form. Once I make a selection for a row in the form, the listbox automatically assigns those values to all the rows instead of on a per row basis.
Does anybody know how to change this option such that the listbox assigns the values per row?
I am doing this via the clickable solutions since I do not know any VBA code.
This happens when the listbox is unbound - then the value selected is common for all visible records.
So, create a field in the table used as source for the form. Then bind the listbox to this field.
I am very new to Access and VBA but what i'm trying to do is simple:
I have a table which i want to show in a form, i have put said table in a subform box.
I want to have a column in which i want to update the status based on options from the combo box (yes/ no/ maybe).
So as shown in the picture: i want to select a line in the subform and update the column status by selecting an option in the combo box.
You can modify the selected record in the subform in the AfterUpdate event of the combo box.
Private Sub cboStatus_AfterUpdate()
subForm1.Form!Status = cboStatus
End Sub
This assumes that your combo box control is named cboStatus, your subform is named subForm1, and the field you want to update is named Status. It also assumes you aren't using numerical ID's as foreign keys for your values.
You will only be able to update one row at a time.
Beyond the scope of your question....
There are numerous other ways to develop an interface to edit the row. One way is to modify the field Lookup properties in the table. You can change the Display Control to a Combo Box, set the Row Source type to Value List, and then set the Row Source to a list of possible values separated by semicolon.
Now whenever you open that table in a datasheet view (like the example on your subform) a dropdown will appear in that column. A user can edit directly in that view without requiring a separate combo box control.
I've got a little problem with passing the value of a combobox to a query which I would like to use to populate another combobox.
There is a large table containing the columns: AutoID, Projectname, Projecttype and some more which I want to filter for certain records.
The first combobox is populated by a different table containing: AutoID and Projecttype (I use this already to create the records in the previous table). This combobox is bound to the first column (AutoID) but I display the second one. What I want
to do is to choose a "Projecttype" and populate the second combobox with all the corresponding records and display the "Projectname" for further processing.
I already read that it's not possible to use a combobox selection directly in a query and you have to go for a public function. I created this function (using the listindex to get the AutoID from the corresponding Projecttype) but can't pass it to the query (don't get any results although the value is correct!
Is there a "better" way to filter records (based on combobox selection) and populate a second combobox?
Thank you in advance!
Moritz
Why do you have AutoID and Projecttype in both tables? Looks like you could possibly do with some normalisation here.
To do what you want with the combo boxes, first of all define a global variable in the module where you've put your public function (I'll call it glngAutoID). The public function should just return the value of this variable, and then you can use this function in the query for the second combo box. In the AfterUpdate event of the first combo box put
glngAutoID = combo1
combo2.Requery
You shouldn't need to use the ListIndex property to get the AutoID because you've bound the combo box to the first column.
I have a form that's just a list of descriptions (desc.) of other forms. Right now, when you click on a desc., the appropriate form opens; but it's done through a series of if statements in a macro. This isn't going to scale well once more forms are created.
I have a table that has the desc. and the form that is supposed to go to. I want to write a script that uses this table to open the new form based on the desc. clicked, but not using if statements. The end goal is to be able to just add a row to the table for any future forms that are created without making changes to the script or form. Is there a way to do this?
Use a combo box whose row source is a query which selects the form description and name fields from your table.
The combo will have 2 columns. You can set the width of the form name column to zero if you want to present only the form descriptions. If you make the form name column the combo's bound column, you can reference it conveniently in a DoCmd.OpenForm statement. For example, you could have a command button whose click event opens the form which is currently selected in the combo ...
DoCmd.OpenForm Me.YourComboName.Value
I have a table with a 'category' column, a form which hides the category column, and a combobox to filter the category, let's say R, C, and F.
I want to have the value of the comobox applied to the hidden 'category' column when a user enters a new record into the form.
Is there I way I can get an instance to the record as it's being entered and modify the data using VB? Or would I have to write a sort of pop() function and have it run afterInsert and then modify it that way? Can I even alter the table using VB like this?
simplest answer is bind the category field to the combo box.
otherwise use the afterupdate event to do: me.category = combobox.value