Dynamic list for drop-down menu - vba

In colunm "A" I have a list that will be filled up by the user; it starts at "A5" but I don't know where it will end.
In column "B" I'd like to make cells look like dropdown menus where items in the list will be the values from column "A".
And whenever the user adds a value to column "A" this should be automatically added to the list.

Create named range (say colA) with formula:
=$A$5:INDEX($A:$A,MATCH(2,1/($A:$A<>"")))
and then use Data validation with named range colA:

In Column A, set up your starting data list as a Table (select your list and then Insert/Table).
Give your new table a nice name (select the Table then go to Table Tools/Design/Table Name).
Tables in Excel automatically expand when a new value is added to an existing Table.
Next, select this same starting data list and create a Named Range. Go to Formulas/Define Name.
Give your list a Name (for example, "List"), and in Refers To enter your Table name. (e.g. type "=Table1" if that's the name of your Table)
I am assuming that for your Column B, you want Data Validation - it puts the dropdowns in each cell as you suggest.
Select the range of cells that you are going to validate, then go to Data/Data Validation.
Under Settings, choose Allow = List.
Under Source type the name of your Named Range that you set up in Column A. (e.g. type "=List").
Add an Input and Output message to your Validation (optional but helpful).
Click OK to close.
Credit to Chandoo.org where I learned this.

Related

Using a property control to use unique values in a column for a Spotfire calculated column

I am creating a calculated column (C) that uses a column property which is set through unique values in a column (B) which itself is set through a column selector. When I change the the data in this Column B (and column type remains the same) my calculated column (C) is not being updated appropriately. I know I am likely making a simple error but I can't figure it out.
Column B = [${Surface.Property}] #This property is set with a drop down menu where I choose which column (e.g., Column A or Column D (each have their own unique values but they are both strings)
Column C =
MostCommon(case when [Column B]="[${MyData}.{Column B}.{Surface.Selector}]" Then Min([Depth]) OVER (Intersect([Location],[Column B]))
else NULL
END) OVER (Intersect([Location]))
This series of calculations works perfect if choose Column A in the drop down menu "Surface.Property" which is use to set the column/values of Column B. However, when I change and select Column D as Surface.Property, the calculation no longer works. Im guessing this is the result of of "unique values" change but I'm not sure how to make this part of the calculation [Column B]="[${MyData}.{Column B}.{Surface.Selector}]", accept "new" values.
Any thoughts would help and hopefully this is somewhat clear!
Figured it out, it turns out I need to insert the column property into my calculated column As Value rather than As Text.

How to add a record into table, that is related to another table?

Good day!
I have two tables.
TABLE 1:
GENERIC [GE_ID / number] [GE_DATEIN / date] [GE_PERSON / number] + ...
TABLE 2:
WORKFORCE [WF_ID / number] [WF_NAME / text] [WF_SHIFT / number] + ...
Column [GE_PERSON] from table #1 is related to the column [WF_ID] from table #2 as many-to-one relationship. I have a simple form to add a data to the table #1 with several drop down boxes. One of these drop down boxes contains a list of names taken from table #2 (column [WF_NAME]) by SQL statement.
So when I am ready to add a record to table #1, I know the person name chosen from drop down box, but column [GE_PERSON] is numeric and I have to add a number equal to the column [WF_ID] which is pointing on name in table #2 (column [WF_NAME]).
QUESTION: how should I build the SQL statement (INSERT INTO) to make this work?
Thank you!
MS Access' combobox control allows the bound column to be hidden from the user while showing identifiable data columns that correspond to hidden field. See this section of MS tutorial. Once you do so, you will have a relevant number for your querying needs.
Brief steps to hide and set primary key as bound column:
For the [WF Names] combobox, include [WF_ID] in the Row Source query under Data tab of Property Sheet as first column:
SELECT [WF_ID], [WF_NAME]
FROM [WORKFORCE]
Under Data tab make [WF_ID] the bound column by placing 1.
Under Format tab, set Column Count to 2 (or more for each field in query) but give Column Width to first column nothing, something like: 0; 2
Now the combobox's value is the corresponding [WF_ID] of the selected [WF_NAME] in drop down list, so any query pointing to the control will be a valid number:
INSERT INTO [GENERIC] ([GE_PERSON])
VALUES (Forms!formname!WFNamesComboBox)
SELECT * FROM [WORKFORCE]
WHERE [WF_ID] = Forms!formname!WFNamesComboBox

Dynamically Changing Value in APEX Based on Select List Selection

I currently have a select list with the values: 1, 2, 3, 4 & 5. These correspond to a column in table "DVD" called "DVDID", and these are the only values in this column in the table.
In the table "DVDCOPY" records exist containing the all DVDIDs (1,2,3,4,5) with a different DVDCOPYID.
E.g. a record from the DVDCOPY table is:
DVDCOPYID DVDID DISCCONDID
1 1 1
My question is, how can I make it so that once a DVDID is selected from the select list, the DVDCOPYID changes dynamically based on this selection? E.g. once 1 is selected in the DVDID select list, the value for DVDCOPYID also changes to 1 automatically.
My form currently looks like this, if this helps:
APEX Form
You have to use dynamic actions and PL/SQL. Create a hidden form element which allows for element changes (no session protection enabled). Create a new dynamic action in your form guiding to the select list and using the onchange event. Your dynamic action contains two steps: first set the hidden form element to the value of your select list. Second: execute a PL/SQL statement (UPDATE DVDCOPYID SET ... = :NEW_HIDDEN_ELEMENT WHERE ID = ...).

Populate column using single cell value from a different column with SQL

I am trying to populate an entire date column in an Access database with a single date value for when the data was collected. The date value is contained in each table, but I want a separate field containing the date in each row. When I used this code it only populated the one row in my new field (sampling_date) where the date is located. The date is located in the sampling_info field on row 4
UPDATE table SET [sampling_date]=[sampling_info] WHERE [point]=4;
Thanks for any help,
Paul
It sounds to me like this is what you're after
UPDATE [table] SET sampling_date = DLookup("sampling_info","table","point=4")

Text and value to combobox Excel VBA

I have two tables in Excel
First Table: Table Students: ID, last name, first name address and etc.
Table Two: Notes on the students: each student can have some records,i have two columns of this table. student ID and comments
The table I want to fill out a form
Will form a combo box with all the students and a text box for entering notes, the Add button will add the records
I wanted a combo box will appear the name of the student (last name+first name) and when they click Add, the code will put the ID student's of the selected student
I thought Combo Box can be set for each row: text and value, the text view and the value is not
As in ASP.NET
dropdownlist.datatextfield = Name
dropdownlist.datavaluefield = ID
Now I see only text can be set
Am I wrong and I can not well known, and if not how can I solve the problem
you have declare two combo box
one with the names and second with rhe id
the id's combo box there is disables
Order of the two combobox will be listed as the order in which it appears in the table
To get the ID of the selected student:
cbxId.List(cbxNames.ListIndex)
You can create a ComboBox with 2 columns - value and text.
In Excel, define the 2-column range and then use that as the rowsource for the control.
In the combobox properties, use BoundColumn = 1 and ColumnCount = 2, with the ColumnWidths values = 0pt; 20pt.
This mimicks the classic HTML 'select' control quite well I find, as you can simply call the Value from the control and as you've set the bound column to be the 'value' column, then it returns your ID for you quite easily.
combo box properties
results when cmd is clicked
raw data