Access current row value (Table Edit mode) - ms-access

I'm trying to get a query up but this doesn't work.
I have t
In the edit mode, i want a Choice List to be filtered depending on the value of the column on the left.
I edit the SQL query, but what is the command to access the current row value of the field on the left?
Thanks guys :D

If this is a table or query, I'm not sure that this is possible. The query you enter into the RecordSource property is running independently of the Datasheet view of the table/query you are currently in.
If this is a form, then you can refer to the value of a form control for the current record as follows:
Forms!FormName!FormControl

Related

Query does not filter results on another field

I am trying to use a field (Combo Box) on MS Access in order to filter the results available on another Combo Box field.
The main purpose of this operation is to show only records of the exact user, which one can choose on the "user" combo box. To do so, I use a query.
No matter what I do, it just does not filter the results.
However, if I open the query, it shows a table with correctly filtered results.
And if I type in manually user ID, it also works fine.
What am I doing wrong?
Thank you!

MS Access-Using value from a form in a calculated field of a table

I have a text box in a form which accepts a date.
I have to use that date in the calculated expression in a field of a table.
Initially I have tried to use this statement in the calculated expression.
[Forms]![Input data form]![Text38]
But it shows that "The expression cannot be used because refers to another table".
How to access the value of the text box?
I think I understand your question. You have a table and you want to use a calculated field in it that references a value in a form.
You will not be able to do it that way. The reason you are getting an error is because the form data only exists when the form is running. If you used that expression in the record source query of the form, you would be ok.
You have a couple of choices depending on what you are trying to do with the data. If you REALLY NEED a calculated field in your table, you can use a form to make an UPDATE to another field in your table; then it is static data and your calculated control can work.
Another option is to have a separate table to store the user input value, then use a VIEW (QUERY in Access terminology) to join the data together and compute the result. Depending on why you are doing it, this is typically the method you want to go with.
If this does not answer your question and you have something more specific, I will try to tailor the answer more.

How make appears a field from the field list automatically?

I just started to use Access with vba. I have table with roles, years and its workload of each role in this specific year. Each record in the table is IDRole, IDYear,Workload (number).
I display the table in a form doing a crosstab table where the years are in the columns and the roles in the rows. The number of years can increase.
My problem is when I add new years and display in the columns, it doesn't appear in the form so I have to select from the field list manually but I would like to know if there is any way in VBA that when the form is load, automatically appears the new columns (years).
I misunderstood your situation. Your form's crosstab data source is actually a table instead of a query. And as you add columns to that table, you want the new columns to automatically appear in the form when you next open the form.
In that case, use the approach described below, but where I selected a query (Query.qryFoo2) in the Source Object dropdown, choose your table ... Table.YourTableName ... in that dropdown.
The last 2 paragraphs below apply whether your data source is a table or query.
If you have your crosstab query saved as a named query, you can use it as the Source Object for a subform control.
Then when you switch from Design to Form View, the query results will be displayed in Datasheet View within the subform control.
As the number of columns changes over time, that Datasheet View can "automagically adapt" to display them ... the same as if you opened the named query directly in Datasheet View.
As far as I'm aware, there is no other reasonably simple way to accomplish what you want. If this suggestion is not suitable, you can explore programmatically adding bound data controls to your existing form after examining the set of fields the query currently returns. But that is way too much effort IMO.
I have exactly the same issue, I have a form which I use to show a Query, And I can't anticipate the number of columns from the query.
I found the same topic on other pages, and for the moment the only way I found is to build an excel file based on the query.
Another way also is maybe to directly open the crossTab query using vba.

Form button that runs query that is bound to value in given record field

I have a 2007 Access form, in "continuous format". I added a button to the “detail" section. Tje purpose of this button is to run a query. I cant figure out how to make this button’s query become bound to a field value in the given record. Instead, it runs the query for all records in the table. Please advise how I can have the query only run based on the value of a specific field for the given record . Is it possible to accomplish this with out VBA?
Thank you very much in advance
Alter your query to refer to your form. Like so:
SELECT ID, Stuff FROM MyTable WHERE ID = Forms!MyForm!ID
Where ID is whatever field you choose to match. It will always refer to the line where the button is clicked, because that is the current record.

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.