I have a table connecting three tables, one each for staff, items and programmes:
Staff 1-1 Programme (Each staff member can only be assigned to one programme at any given time)
Staff 1-many Items (Each staff member may request for more than one inventory item)
I create a form for this table, on which I create a combo box to allow the user to select multiple items.
How can I make it such that if for instance the user enters his/her staff ID and his/her programme code and checks off three items, then three records are saved in the table (instead of one record but with multiple values for that field)?
The short answer is you cannot use a multivalue field to created a new record for each checked combo box item unless you want to get into really complex VB Scripting. However, you can do a printout of multivalue fields by creating and running a SQL statement, which does actually present the information exactly how your describing/requesting.
You can set the Row Source for a textbox or combobox on a form by going into the forms Design View and then click on the field text entry area then under Property Sheet > Data > set a SQL Statement to equal different tables to acquire the values you are referencing and then set the Control Source (above Row Source) to the output fieldname/table where you want to store that information.
SELECT tblName.FieldName1.Value AS FieldName, tblName.FieldName2, tblName.FieldName3 FROM tblName;
tblName.FieldName.Value AS something that's not x.Value because x.Value is the individual entries for each multivalued combo box entry for the entire table where this information is "~stored".
If you run the SQL Query above (obviously change to what your actual tables and fieldnames are) then you will see a temporary table (a view) with all the individual values of the multivalues like a printout.
OR
CREATE TABLES: Where I mention references do the steps above but remember you may need to set a condition using WHERE something = something AND OR something.
Staff Programme Table: [UniqueRowID], [StaffNum], [Name], [ProgrammeName], etcetera
The ProgrammeName column references the ProgrammeName in Programme Lookup table. You need to set the fieldname "Display Control" under "Lookup" to combobox then set Row Source to SQL statement like previous mentioned so it knows where to get the values for the programme name.
Programme Lookup Table: [UniqueRowID], [ProgrammeName], etcetera
This contains all values that exist. Easy to update and maintain.
Staff Items Table: [UniqueRowID], [ItemName], etcetera
The ItemName column references the ItemName in Inventory Lookup table. You need to set the fieldname "Display Control" under "Lookup" to combobox then set Row Source to SQL statement like previous mentioned so it knows where to get the values for the inventory item.
Inventory Lookup Table: [UniqueRowID], [ItemName], etcetera
This contains all values that exist. Easy to update and maintain
OR
Alternatively, create another table that contains the values you want. Then create a SQL statement:
INSERT INTO newTableName(newfield1, newfield2, newfield3, etc)
SELECT sourcetblName.sourceFieldName1.Value AS FieldName, sourcetblName.sourceFieldName2, sourcetblName.sourceFieldName3 FROM SourcetblName;
Related
I'm new to SSRS Reports.
I have an SSRS Report that takes a list of category Ids
And I stored procedure that called SP_GetProductsByCategory that takes categoryId
I want to create the tables dynamically according to the list.
If it takes 3 Ids , a 3 tables will be create with 3 procedure calls.
This is fairly simple to do using subreports.
First create a report (let's called it singleCategory) that accepts a single categoryId as a parameter (call the parameter pCategoryId for example). Setup the report so that it produces the table you require but just for this single category.
Once that is done, test it and make sure it's working as expected. Remember this should only accept a single categoryId.
Note:
I'm assuming your users will select categories from a database driven parameter list...
Next, create a new report (e.g. CategoryMasterReport) and add a dataset (dsCategories) to get a full list of available categories for the user to choose from. This might be something as simple as SELECT categoryId, categoryName FROM myCategoryTable.
Next, add a parameter (pCategories for example). Make this a multi-value parameter
Set the available values for the pCategories parameter to the dsCategories dataset and choose label and value columns as appropriate.
Now create another dataset, this one will list all the categories selected by the user. Call it dsSelectedCategories and set the query to something like...
SELECT categoryId
FROM myCategoryTable
WHERE categoryId IN(#pCategories)
Next, add a table to your report and set it's DataSetName property to the name of the dataset we just created (dsSelectedCategories). We only need one column in this table so you can remove the rest. You can also remove the header row.
In the table's remaining textbox, right-click and choose "Insert ==> Subreport". This will fill the textbox with a subreport placeholder. Right-Click the subreport placeholder and choose 'subreport properties'.
In the general tab set the subreport to be used as the one we created at the start of this (e.g. singleCategory).
In the parameters tab, click 'Add' then either choose the name of the parameter from the drop down list or type it in (following the example names from earlier this will be pCategoryId). For the value property, click the drop down and choose the categoryId field (if you followed closely this might be the only field listed.
That's it.
Now run the main report (CategoryMasterReport), select some categories from the list and you should see a table for each selected category.
I've coded my entire database to rely on recordsets and updating those recordsets on click of record IDs within other forms. Then I discovered that I can't edit the records from the datasheet. So I need an alternative.
My database consists of the following tables: Customer, Address, Order, Details, Contact and Misc. Each of these tables has a PK which is stored in a table called Master_Bridge which constructs a unique combination of all the PKs.
I have a form which includes each of these tables as a subform. The user begins at the Customer subform. When they click the Customer_ID, the Address table needs to filter based on where that Customer_ID exists within the Master_Bridge.
I was hoping to store each of the IDs into a recordset, or an array of some type, and translate each of those values into the filter. Admittedly, my VBA isn't good enough that I know how to do that.
I also tried a nested select in the recordsource of the Customer form, where I selected all of the Address_IDs. Again, couldn't edit.
Do you folks have any suggestions on how to proceed with this? I'll also need the click of Address_ID to filter the Order form by using both the Customer_ID and the Address_ID. The rest of the tables/forms will utilize the above 3 IDs.
Sorry if this is a question which is ask many times, but im new to access and have no idea how this matter is called.
In Access I have 3 tables. The first one is Projects
Table Projects has many columns, one of them is Project_Name.
Second table is WBS
Table WBS has also many columns, one of them is WBS_Name and other is Project (which is a dropdown based on Project_Name from table 1).
Sample:
WBS table sample
The third is Orders, here is where im stuck.
Table Orders has a column called Order_Name, also in this table I have a column called Project (which is also based on Project_Name from table 1. The last column (WBS_Product) is a multiselect listbox with values from WBS_Name from table 2.
Order table sample
Now in this third table I want to see in the WBS_Product row only the values available for selection based on the Project selected in the second column.
You REALLY should be using forms if you want to customize your data entry like this. Because you're entering data directly into the tables, I don't believe this is possible.
I have 2 related tables.
Invoice (fields: number, buyer, supplier, etc.)
Company - all buyers and suppliers (fields: name,etc.)
Buyer ans supplier fields on invoice are referencing same field (company_id from company table)
On invoice form, I choose supplier ID from dropdown list and also buyer ID from dropdown list.
Task: To make the form little bit readable, I would like to automatically display a name of company after selecting company id in both fields.
What I did:
I manually dragged the company name field to the form and wizard asked me which field I would like it to connect to (byuer or supplier), so I got 1 field working. How to create another field that shows company name? If I drag another instance of company name, wizard does not show so I can set it up and I can not find anywhere setting for that. Thank you for help.
I think the best way is the following:
Create a lookup query: Create a new query similar to this “SELECT CompanyId, CompanyName FROM t_Companies ORDER BY CompanyName;” and save it as “ql_Companies”
Edit your Invoice table. For both your fields Buyer and Supplier do the following: Click on the field and select Lookup in the filed properties. Set the following properties: Change Display Control = Combo Box, Row Source = ql_Companies, Column Count = 2, Column Width = 0;5 and save the table.
Now when you create a new form based on your Invoice table the field will be automatically shown as a combobox.
You can also do all this manually on an existing form but then the combo box will only show on this one form. If you prepare the underlying table with lookup queries then this will work in all queries and forms automatically without additional work.
Here is my problem and I do not know where and how to start to search about this.
In a MS Access database users will have a list of records returned from a query. Let's say employees which are active (employed). This table has a related table let's say departments (related through departmentID in both table).
What I want to do is to make form (or something else which would do the same job), where user will select some records (probably with checkboxes associated with each record) and there will be a single combobox with department names. When user selects a department name, its departmentID should be saved into departmentID field of these records.
I have created a form with a query of active employees (form with multiple items). And put an extra field in Detail section with a checkbox. In Form footer I have a combobox with Department names and IDs (not shown to user), and a button to save values.
I have to now figure out, how to select all rows/records with a checked checkbox and update them. I am by the way familiar with VB and SQL.
I would appreciate any idea/knowledge on how to solve this.
An extra field in the Detail section won't help you if you don't link it with a data field in the displayed table. If you can do that, then you have simply to make a VBA function to update all selected rows, and refresh the recordset.
If you cannot modify your table, you'll have to create a new table with just the key columns of your master table, and manage it via VBA. Better to use the first option if you can, it pollutes your schema, but in most cases that won't be a problem for an Access database.