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?
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 have multiple datasets with the WHERE clause = #customernumber.
I have a customer number data set that contains a field with a unique id and a field that contains multiple ids.
I.e.
Customer Number | Old Customer Numbers
123 123
123 34324
123 4363
123 124214
345 345
345 436346
345 234532
678 678
I want to be able to search in the parameter box for the old customer number but use the customer number in querying my datasets.
My datasets only contain the customer number, not the old customer numbers.
While creating the parameter you can select the value and the label of the dropdown list.
In the Available Values tab select Get values from a query, for dataset just choose the dataset that query the table with new and old codes. In Value field select the new code and in the Label field select the old code.
UPDATE:
Create a parameter called OldCode. Set the data type to text or integer based on old customer code number. Don't use default or available values for this parameter.
Create a dataset that use the #OldCode parameter to return the customer number. Use something like this:
select
Customer_Number
from CustomerTable
where Old_Customer_Number = #OldCode
Create a parameter called CustomerNumber. Set Hidden property and select the data type based on the Customer_Number column. In Default Values tab select the dataset created previously and the Customer_Number column as Value field.
After that you can use #CustomerNumber in all your datasets. When user input a old code the #CustomerNumber will be populated with the related Customer_Number value.
Let me know if this helps.
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 = ...).
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