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
Related
First time poster, long time Junior Varsity Access Developer
MS Access 2016 on Win 10 system (not connectable to public network)
I have form with a text field - Event Name (Pulled from existing value in Events table) and 3 unbound combo boxes (created from Wizard, select key field and lookup value text, hide key field, save value for later use) on a form that each pull values from a respective lookup table
Lookup table structure:
tblCategories: CategoryID (PK, Integer) | CategoryName (Text 255)
tblDirectorate: DirectorateID (PK, Integer) | DirectorateName (Text 255)
tblLocation: LocationID (PK, Integer) | LocationName (Text 255)
What should happen:
User completes the form, selects values from each of the combo boxes (Category, Directorate, Location) clicks Save Event button. (Tested - Values passed to SQL statement correspond to values from combo box)
Update SQL Statement runs, updates Events table and sets values in table to values on form (Update SQL Syntax correct, I did a debug.print to immediate window, copy and paste to QBE, run SQL, Update runs correctly)
What does happen:
User completes the form, selects values from each of the combo boxes (Category, Directorate, Location) clicks Save Event button. (Tested - Values passed to SQL statement correspond to values from combo box)
Update SQL Statement runs, updates Events table and sets values in table to values on form (Update SQL Syntax correct, I did a debug.print to immediate window, copy and paste to QBE, run SQL, Update runs correctly)
(Here's the part that I can't explain) The value of CategoryName in tblCategories updates to the value of CategoryID
a. I do not have cascade updates on any of the tables
b. Nowhere in ANY of the code in the entire DB is there a SQL statement to update tblCategories
c. Nowhere in any part of the DB is there a command to update the value of CategoryName in tblCategories
d. Neither the values of [tblDirectorate].[DirectorateName] nor [tblLocations].[LocationName] update to their corresponding ID field value.
I'm completely befuddled by this. I've deleted / recreated the combo box for the Category lookup, verified that the actions / properties for all 3 lookups are the same.
Has anyone previously experiences this, or can throw out some additional troubleshooting ideas?
Thanks!
Jordan
I would like to insert multiple entries into a table using a single form.
Desired outcome:
DESTINATION_TABLE
DATE | PLACE | THEME | PARTICIPANT
dd.mm.yyyy A X 1
dd.mm.yyyy A X 2
dd.mm.yyyy B Y 3
PLACE and PARTICIPANT are to be selected from values contained in other tables, while DATE and THEME are entered using text boxes. Only one value is to be inserted into the table at a time for DATE, PLACE and THEME, but I would like to be able to insert multiple PARTICIPANT, with a new row for each PARTICIPANT selected.
Adding new entries for DATE, PLACE and THEME via a form works (using CurrentDb.Execute "INSERT INTO...).
How can I create a form that would let me select PARTICIPANT from a subform (ideally with checkboxes) filtered from the value in PLACE, and add an entry in DESTINATION_TABLE for each PARTICIPANT selected ?
One simple way of doing it, with your current setup is to:
add a Yes/No field to your participants table, default to No. We'll call this field Selected
Bind your subform to the participants table, the user will be able to check each participant from this view(using the Selected field).
From which ever event you're using to save you data(e.g. Button Click), create a recordset(rs) based on the selected participants from the participants table(SELECT * FROM PARTICIPANT WHERE Selected = True. Loop through each record in the recordset(rs) and execute your code CurrentDb.Execute "INSERT INTO...), taking the value of the participant(rs("Participant")) from the recordset.
Once the loop is finished, update the participants table setting the Selected field to No. CurrentDb.Execute "UPDATE PARTICIPANT SET Selected = False WHERE Selected = True"
Refresh/Requery your sub form data if needed
Substitute above object names with yours.
I am trying to update a value in a table from an unbound form. The user needs to choose the product name, enter a sales value and then the value updates the correct record in the table. At present I have:
UPDATE tblStock
SET tblStock.Sold = [Forms]![frmItemsSold]![Text3]
WHERE ((([tblStock]![ProductName]=[Forms]![frmItemsSold]![Combo1])));
The form is frmItemsSold and Combo1 on the form has the product name. Text3 on the form contains the sold value which should update the correct record in the Sold field in tblStock. At present my code doesn't work. Any ideas?
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 = ...).
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.