How do I set up a calendar in MS Access - ms-access

I am trying to set up a calendar in access where I can put in Customer information for specific dates. I must be doing something wrong, please help.
The table list that I would like to link has these headers
ID :Customer : Date: Status: Hours
example:
2: Tax Services: 07-Mar-14 :completed: 11-12
5: Discount Tire: 25-Mar-14: Call

In order for a data bound Form to be editable, the form must be either based on the table or on a query that is updatable.
A query is not updatable if it contains a DISTINCT clause (Unique Records property set to Yes) or if it is a UNION query or has a GROUP BY clause. Cross-table queries are not updatable. SQL Pass-Through queries are not updatable. A query joining tables containing a many-to-one-to-many relationship is not. A query containing aggregate functions (COUNT, SUM, MAX etc.). A query containing a sub-select in the field list.
The Form must have the AllowEdits property set to Yes. If you want to be able to add or remove records, also set the AllowAdditions and AllowDeletions properties to Yes.
Set DataEntry to No as this means that a new empty record is created each time you open the form.

Related

MS-ACCESS - Using returned value from DLookup as part of calculation

Please don't laugh. I'm sure this is something simple for all of you but as a novice, I'm in need of help.
I have an invoicing form which contains a subform. The subform allows users to select products and quantities.
For each product selected, users enter a quantity and the subtotal is automatically calculated. This part is fine.
My problem is, when I want to provide an overall total in the footer of the subform, I am just getting £0.00.
Here are the details:
Field one is called "Unit Price". This unit price is found using DLookUp. The formula is "=DLookUp("[Price]","[tblCashPrices]","[ProductID]=" & [Product] & "AND [SalesTypeID]=" & [Forms]![tblInvoice1]![SalesTypeID])"
This auto-populates and seems to be fine.
Field 2 is called "quantity" and is just a number field where users can enter an integer.
In the subform, I want to generate the overall total. I have tried "=sum([quantity] * [unit price])"
This is just returning £0.00.
I don't know what is going on because my subtotals for the products work but the overall total doesn't?
Please help
Aggregate functions must reference fields from table or query used as the form RecordSource, not a calculated control.
Better options than DLookup() on form to retrieve related data.
include the lookup table in the form RecordSource, join type: "Include all records from tblInvoices and only those from tblCashPrices that match."
multi-column combobox for the products, the price can be in a hidden column, then a textbox can reference the combobox column by index
Option 1 will allow the Sum() function to reference the Price field. Optionally, do the DLookup() calculation in a query and use that as the form RecordSource. Then the calculated field can be referenced in Sum() calc. Just be aware domain aggregate can be slow performer in query or textbox.
Another option is to create a field in table to store the price. Then use code (macro or VBA) to execute DLookup and save the retrieved value into that field.
Also, your DLookup() has syntax error in the WHERE argument. Need space each side of AND.
Record must be committed to table before the Sum() calc will update. Record is committed when: 1. close table/query/form; or 2. move to another record; or 3. run code to save.

Ms Access: Running an update query

I got a query which takes out some fields from a table.
How do I use the same query to create a sum of the values of those fields and update the sum to a single field in another table?
If you must do this, the only way I can see to accomplish without VBA uses DSum() domain aggregate function.
UPDATE tablename SET fieldname = DSum("some field", "some table", "some filter criteria here")
Trying to do this with a nested aggregate query in place of the DSum() returns error 'must be an updatable query'.
Really should re-think your db design.

Access - Enter Parameter Value Error

I have a table that contains all the weeks of the year (using the client's numbering, so Week 1 is in June), and the dates they start. There is a form where they can choose which week they want to look at, so I've used a ComboBox that grabs all the week numbers for which they've entered data in the WeeklyHours table, using
SELECT Format(WeeklyHours.Week,"0") AS Expr1 FROM WeeklyHours GROUP BY WeeklyHours.Week;
This combobox is then supposed to be used as the week filter for a couple queries I've built, using the combobox value as the matching criteria. The problem is that when the form is closed, those queries can't run, and give me the Enter Parameter Value error for the combobox value.
To fix this, I tried to create a new table called SelectedWeek with a single entry called Week_Number. There is then some AfterUpdate code that saves the selected combobox value to the Week_Number field of SelectedWeek.
I then changed the queries to point to [SelectedWeek]![Week_Number], so that the queries will always use whatever the most recently selected week was.
However, I keep getting the Enter Parameter Value error for SelectedWeek!Week_Number, and I can't figure out why.
Any help would be most appreciated.
Thanks,
Joel
Reason the user is prompted for Parameter Value (by the way, it is not an error) is in both cases the Access SQL engine cannot see either referenced values. In first case, the form is closed and in second case column is not properly aligned to a lookup.
In first scenario, simply keep form open which user selects value from combobox when running other queries. Otherwise, all content on form is not callable since it is closed from memory:
SELECT * FROM TableName WHERE weeknumber = Forms!FormName!WeekNumber
In second scenario, use a DLookUp() part of the Domain Function Family.
SELECT * FROM TableName WHERE weeknumber = DLookUp("Week_Number", "SelectedWeek")
And really, domain functions can be generalized as subqueries in SQL:
SELECT * FROM TableName
WHERE weeknumber IN (SELECT Week_Number FROM SelectedWeek)
Even more, you can run a cross join query (tables separated with commas in FROM clause) of the two tables and avoid lookups. Below assumes SelectedWeek is a one-row, one-column table but with the WHERE condition, length is handled and you can explicitly declare columns in either table:
SELECT *
FROM TableName, SelectedWeek
WHERE TableName.weeknumber = SelectedWeek.Week_Number

Data filtering on form generates "Could not find field"

I spent half day trying to figure out why appears an error messagebox
Could not find field 'TransactionTypeID'
in my
database. If you open Form1, then apply any filter on column TransactionTypeID using header (for instance, uncheck Blanks) and then try to open sorting/filtering for second column, appears error message.
Error disappears if I convert combobox to text box or remove from form select table Tenants1. I use Access 2010 32 bit. In this example I simplified tables as much as possible, database created from scratch, data imported, compact/repair doesn't help.
Do you have any ideas?
I found the problem. The built-in datasheet form filtering works in a wrong way if tables joined this way:
SELECT VouchersMain1.VDate, VouchersMain1.TransactionTypeID
FROM Tenant1 INNER JOIN VouchersMain1 ON Tenant1.TenantID = VouchersMain1.TenantID;
If I reverse tables join direction, built-in filtering works fine:
SELECT VouchersMain1.VDate, VouchersMain1.TransactionTypeID
FROM VouchersMain1 INNER JOIN Tenant1 ON VouchersMain1.TenantID = Tenant1.TenantID;
Looks like this is another Access bug.
Also, thanks #Munsterlander, problem disappears if form's recordsource replaced by saved query instead of SELECT
Try referencing your field as Forms!FORMNAME!CONTROLNAME. I assume, based off what you wrote, you are trying to filter a query based on what is selected in the combobox.
Delete the table Tenants1 from your form RecordSource (this table is not necessary and do not exposes fields in the resulting query).
You would also note that your recordsource is set (by Access) ReadOnly (bad design, no join defined). Try to add a couple of Records in the Tenant1 table, say it David and Nathan.
You will find that now your query will output 6 records (and not 2), because the query (with no joins) list one row for all records of table Tenant1 (3) and one row for each record of table VouchersMain1 (2), giving a total of 2*3=6 rows.

Update Table Column off of Query Column

I am trying to Update a column in my table Inputcounts called concatenate off of a query called InputConcatenates that has a column also called concatenate. I am running an update query with the field name as concatenate the table name as InputCounts and the update to field as [InputConcatenates].[Concatenate]. But every time I run the query it pulls back that 0 records will be updated. Is my syntax wrong possibly?
Update Query SQL:
UPDATE InputCounts INNER JOIN InputConcatenate
ON InputCounts.CONCATENATE = InputConcatenate.CONCATENATE
SET InputCounts.CONCATENATE = [InputConcatenate].[CONCATENATE];
InputConcatenate Query SQL:
SELECT InputCounts.FLEET, InputCounts.AMMs, [FLEET] & [AMMs] AS CONCATENATE
FROM InputCounts;
You reported this query accomplishes what you want ...
UPDATE InputCounts
SET CONCATENATE = [FLEET] & [AMMs]
WHERE CONCATENATE Is Null;
That may be fine. However CONCATENATE is not updated until you execute the UPDATE, and does not get updated (after having previously received a value) in response to changes in FLEET or AMMs
Decide whether CONCATENATE really needs to exist as a field in your table. You could use a query to derive it whenever you need it:
SELECT *, FLEET] & [AMMs] AS CONCATENATE
FROM InputCounts;
With the query, CONCATENATE will always be up to date.
If your database is ACCDB format and your Access version is >= 2010, another possibility is to make CONCATENATE a "calculated field" type in the table's design:
If you prefer CONCATENATE be Null whenever FLEET or AMMs is Null, change the field's Expression property to [FLEET] + [AMMs]
The advantage of a calculated field is that Access automagically updates its value without further effort (like executing an UPDATE) from you.
A disadvantage is that you can't index a calculated field. That means it's not suited for joins, WHERE criteria, ORDER BY, etc. You'll have to decide whether it's a reasonable fit for your application. :-)