Restricting Table to one Row Only Access database - ms-access

I have created a table which holds a date range like startdate and enddate.This is then referred to in query for the date criteria through a Dlookup. The table is filled through a form which is bound to this table.The problem now is if I change the dates,it creates another record in the table and this creates chaos on the query.How do I ensure that there is only one row in the table?

If you want only one record in table then edit existing record, don't enter dates into New Record row. Set form AllowAdditions and AllowDeletions properties to No.
Could instead of saving dates to a table, keep form open and have report reference form controls for criteria. This would also eliminate DLookup. Domain aggregate functions can slow performance.

Related

Subtables in MS Access

I am working on a database that has one main table with the entry rows having an individual table for calculations.
So I have about 9 tables that have calculations /values in that are associated with an individual indicator field entry in my main table. I would like to link the calculation tables to the individual entry.
The subdatasheet allows me to do this. However, it populates all the entries with the same table which I do not want as one calculation table is only associated to one entry.
I can’t create one table for all calculations as they have different types of data and are calculated differently so I can’t link with regards to relationships.
The only solution I can think of is by populating a new field called “results calculations” and populate it with the title of the calculation table associated to the individual entry.
Is there another way I would love all the data to be as accessible in one table as simplified as possible.
(I am new to MS Access so any advice will be appreciated.)
The result of using subdatasheet
What I need to link to each indicator

MS-Access combobox adding record to table that is supposed to be a lookup

I have a form with subforms that has been created from a query that I created. This query has information from 6 tables. The form is separated into basically 3 sections.
The main form is Credit Union information, first subform is Branch information and the second subform is Circuit information based on the branch record that is selected. In the Branch subform I have a combobox that is set up to display the TimeZones table info so that when creating a new branch in the form you can automatically select the timezone.
The issue I am having is that when I select the timezone and save the record, a new record is created in the Time zone table with the same text information just a different ID, rather then what I expect it to do which is add the existing time zone ID to the new branch record.
Based on your question, it sounds like you are hoping to use information from the time zone table to add the field "timezone" to your Branch table. If I'm correct, you would have to add that field to your Branch table in design view first. Then, you go to your combobox properties within your form. Next to row source, type "SELECT [TimeZones].[timezone] FROM [TimeZones] - making sure of course the spelling matches the tables/fields.
Thanks for the input but I was able to figure it out. Instead of keeping the "Time Zone" field on the Brnaches table as a text input or matching the Timezone ID from the Time Zone table, I changed the Brnaches table "TimeZone" field to be a lookup field that queried the Timzone table before the information was added to a Form. Then when the form was created, the timezone entry was already a combobox and already queried the Timzone Table.

Sorting records on a form in MS Access 2010

I had a question last week about how to do a sort of ascending ID numbers by year for a SQL query.
Doing a secondary sort by year in a SQL query
I followed those instructions and the result was great for my table. The data in the resultant query was used to create a table that was then linked to a form. Unfortunately, as I add new records to the table, am I seeing that the sort is not respected after data entry (that is, new records are automatically displayed first when browsing records with the form instead of last). Is there a way to do a sort with ascending ID numbers and year within the form itself? When I try to use the ORDER BY year (date) expression in the form properties I'm getting an "undefined function in expression" error.
Since you already create a new table from the data, you could add a new column to that table containing the "year(date)" result. That way, you have a real column you can ORDER BY on. (ORDER BY yearcol, id)
When inserting, fill it with the current year.

How to select multiple records and change their value at once

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.

Access: Select multiple records to print report

I am trying to design a form where I can select multiple records and on button click open the report with the selected records IDs.
I am thinking maybe make a continuous form with an added unbound check box control where the user selects the appropriate records they want to display in the report. I am unsure how to later read this into a do.cmd OpenReport criteria property.
If there is an easier way to this please let me know.
Take a look at http://support.microsoft.com/kb/135546 or http://allenbrowne.com/ser-50.html. Another approach you could take is create a temporary table that contains a single field for your record ID. Using the code from the links, fill the temporary table with the record IDs that have been selected. Then all you need to do is change the query that drives your report to do an inner join with the temporary table.
Can you add a column to your dataset where they can determine which rows to print? You could add a printMe Y/N column, for example, and then use that field value to limit the rows for the report.