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

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.

Related

SSRS IIF Issue expression [duplicate]

I need a row value in my SSRS report that is a calculated one based on a couple of fields that are already being used in the report. I want it to display in the textbox named 'textboxPercentageValue'. In semi-plain English, the expression/formula is:
If the value of the "Week" field is "WK1", display the value of the Variance field divided by the value of the Price field; otherwise, just display the value from the Variance field.
In VB script gobbledygook, the expression/formula I've add to textboxPercentageValue's Value propert is:
=IIF((Fields!Week.Value="WK1"), Fields!Variance.Value / Fields!Price.Value, Fields!Variance.Value)
Yet, when I try to upload the .rdl file to SQL Server Reporting Services, I get:
"The Value expression for the text box ‘textboxPercentageValue’ refers directly to the field ‘Week’ without specifying a dataset aggregate. When the report contains multiple datasets, field references outside of a data region must be contained within aggregate functions which specify a dataset scope. (rsFieldReferenceAmbiguous) Get Online HelpThe Value expression for the text box ‘textboxPercentageValue’ refers directly to the field ‘Variance’ without specifying a dataset aggregate. When the report contains multiple datasets, field references outside of a data region must be contained within aggregate functions which specify a dataset scope. (rsFieldReferenceAmbiguous) Get Online Help
The Value expression for the text box ‘textboxPercentageValue’ refers directly to the field ‘Price’ without specifying a dataset aggregate. When the report contains multiple datasets, field references outside of a data region must be contained within aggregate functions which specify a dataset scope. (rsFieldReferenceAmbiguous) Get Online Help
The Value expression for the text box ‘textboxPercentageValue’ refers directly to the field ‘Variance’ without specifying a dataset aggregate. When the report contains multiple datasets, field references outside of a data region must be contained within aggregate functions which specify a dataset scope. (rsFieldReferenceAmbiguous)"
So what do I need to do to make this expression/formula unambiguous to SQL Server Reporting Services or the VBScript parser or "whoever" is complaining about it?
It sounds like your Textbox has been added to an area of the report that isn't a "data region" (e.g. a table or list). A data region will have a reference to a particular report dataset as one of it's properties, so Reporting Services knows all field references inside that data region refer to that dataset. What this error is trying to say (in a rather verbose way) is:
if you reference a field outside of a data region, that reference needs to be inside an aggregate expression such as Sum() - this is because the dataset may contain multiple rows for the field but outside of a data region a textbox can only display a single value.
this aggregate expression must also include a reference to the report dataset that the field is coming from
So if field "WK1" was from dataset "MyDataset1", the expression to reference that field would look like:
=Sum(Fields!WK1, "MyDataset1")
See also: Using Dataset Fields Collection References in Expressions
This is an interesting problem, because if you have ONLY 1 data set in your report, you don't need a table, you can directly reference a field that exists in that table.
However, if you have more than 1 data set then you must create a table, which may give you multiple rows. Then you might have to group by this one field, and hide the extra columns and rows. However, you CANNOT display this data in a TEXTBOX, you can however create a rectangle which can hold the table and another textbox. Or display the table directly.
A text box can get knocked out of its context and still appear to be in it. I came by this post looking for the same error message and it was one textbox in a series of several and it had worked just moments before I had readjusted formatting. After getting the info in the first answer, I went back and poked around and found the textbox throwing the error was actually be the list box but appeared to be on the same levels as the others unless I was trying to move or resize the list box. Moving the textbox out and dropping it back in fixed things. As someone coming upto speed on SSRS from a programmer prospective, the insight in the first answer solved a frustration that has come up repeatedly!

retrieving data from a query inside a form

I have a form in MS access which contains information about customers of a store (It's directly connected to the table because I want to be able to edit fields).
I want to have a field inside the form which contains information calculated in a query in the form of (ID, Value)
How is it possible?
Derive data using either VBA or Macro
Since your form is bound, and the field in your query is not a field in the bound table, you can simply add an unbound control to your form. You can use a textbox control, draw on form, and it should default to an unbound control. To check, select the new control and confirm that its control source property is blank.
I am assuming that your query already has form references that are filtering the results based on which record you have open on the form. If not, you will want to put in the ID field's criteria of your query: [Forms]![MyForm]![MyBoundIDControlNameOnForm]
In your form's On Current event. Open the code builder and type this into the On Current event:
Me!txtMyNewControlName = DLOOKUP("[Value]", "MyQueryName")
DLOOKUP has a third argument that allows you to add criteria. I am assuming that your query only returns a single row with the form reference criteria, so there is no need to tell DLOOKUP which row in the query results to return.

How can I "specify a dataset aggregate" in this SSRS Expression?

I need a row value in my SSRS report that is a calculated one based on a couple of fields that are already being used in the report. I want it to display in the textbox named 'textboxPercentageValue'. In semi-plain English, the expression/formula is:
If the value of the "Week" field is "WK1", display the value of the Variance field divided by the value of the Price field; otherwise, just display the value from the Variance field.
In VB script gobbledygook, the expression/formula I've add to textboxPercentageValue's Value propert is:
=IIF((Fields!Week.Value="WK1"), Fields!Variance.Value / Fields!Price.Value, Fields!Variance.Value)
Yet, when I try to upload the .rdl file to SQL Server Reporting Services, I get:
"The Value expression for the text box ‘textboxPercentageValue’ refers directly to the field ‘Week’ without specifying a dataset aggregate. When the report contains multiple datasets, field references outside of a data region must be contained within aggregate functions which specify a dataset scope. (rsFieldReferenceAmbiguous) Get Online HelpThe Value expression for the text box ‘textboxPercentageValue’ refers directly to the field ‘Variance’ without specifying a dataset aggregate. When the report contains multiple datasets, field references outside of a data region must be contained within aggregate functions which specify a dataset scope. (rsFieldReferenceAmbiguous) Get Online Help
The Value expression for the text box ‘textboxPercentageValue’ refers directly to the field ‘Price’ without specifying a dataset aggregate. When the report contains multiple datasets, field references outside of a data region must be contained within aggregate functions which specify a dataset scope. (rsFieldReferenceAmbiguous) Get Online Help
The Value expression for the text box ‘textboxPercentageValue’ refers directly to the field ‘Variance’ without specifying a dataset aggregate. When the report contains multiple datasets, field references outside of a data region must be contained within aggregate functions which specify a dataset scope. (rsFieldReferenceAmbiguous)"
So what do I need to do to make this expression/formula unambiguous to SQL Server Reporting Services or the VBScript parser or "whoever" is complaining about it?
It sounds like your Textbox has been added to an area of the report that isn't a "data region" (e.g. a table or list). A data region will have a reference to a particular report dataset as one of it's properties, so Reporting Services knows all field references inside that data region refer to that dataset. What this error is trying to say (in a rather verbose way) is:
if you reference a field outside of a data region, that reference needs to be inside an aggregate expression such as Sum() - this is because the dataset may contain multiple rows for the field but outside of a data region a textbox can only display a single value.
this aggregate expression must also include a reference to the report dataset that the field is coming from
So if field "WK1" was from dataset "MyDataset1", the expression to reference that field would look like:
=Sum(Fields!WK1, "MyDataset1")
See also: Using Dataset Fields Collection References in Expressions
This is an interesting problem, because if you have ONLY 1 data set in your report, you don't need a table, you can directly reference a field that exists in that table.
However, if you have more than 1 data set then you must create a table, which may give you multiple rows. Then you might have to group by this one field, and hide the extra columns and rows. However, you CANNOT display this data in a TEXTBOX, you can however create a rectangle which can hold the table and another textbox. Or display the table directly.
A text box can get knocked out of its context and still appear to be in it. I came by this post looking for the same error message and it was one textbox in a series of several and it had worked just moments before I had readjusted formatting. After getting the info in the first answer, I went back and poked around and found the textbox throwing the error was actually be the list box but appeared to be on the same levels as the others unless I was trying to move or resize the list box. Moving the textbox out and dropping it back in fixed things. As someone coming upto speed on SSRS from a programmer prospective, the insight in the first answer solved a frustration that has come up repeatedly!

viewing underlying value in access lookup field

If I have a lookup field in Access with the first (bound) column hidden by setting field widths to 0";1", is there a way to see the real underlying value of the field without having to change the formatting of the lookup column?
I don't believe there is a way to access the available values without editing the lookup column.
With that said, I would point out the following:
Changing the formatting of the lookup column only impacts 2 things.
When you navigate the records from the table view you will see the new definition.
Any forms created in the future will now inherit the new definition.
In other words, changing the formatting of the lookup column doesn't impact any forms you may have already created based upon that field.
You can have a more descriptive description in your table that is completely separate from the definition in your forms.
If you want to know all of the values I suggest that you edit the drop down to show a concatenation of columns 1 and 2.
For example, lets say you had a value list of
1;foo;2;bar
The value list could be changed to
1;1-foo;2;2-bar
Then you know at a glance what the "hidden" field value represents. (The same could be done if the record source is a query.)
Turns out that there is a very simple way to do it. In the query, go to field properties and click on the "Lookup" tab, and choose textbox.

Microsoft Access Form To Query for Multi Value Field

I am trying to write an Microsoft Access query from a form with a multi value field being the criteria. The field I am trying to use is called Population and the field is represented in my database as a List Box that allows multiple values and it is in the Building table. The values it allows are the following:
"Singles";"Familes";"Families with Children";"Youth/Young Adults";"Veterans";
The form that I am creating is called HousingSearch.
I am trying to create a form which uses this field, so someone could use the list box and check off the values they want and click on the button which would open a query. I know having done this with single value fields the criteria in the query looks something like
[forms]![HousingSearch]![Building]![Population]
but if you try the same thing for a multi value field nothing is returned for the query. Any help would be appreciated.
From the information you have provided it seems that the phrase [Forms]![HousingSearch]![Building]![Population] are combining a request that starts with a form and then jumps to a table.
You are asking access to find data in a form but the information you're most likely trying to access is in a table. I don't quite understand what you're end result is but I think that you most likely want to refer to your information this way [Building]![Population]. Referring to your data this way makes access look at the table of [Building] and then into the field of [Population].
It's been a while since you posted, if you haven't cleared things up already I hope this helps.