I'm working on a form that, after using a combobox (possible values are only EURO or USD), show the cost in the selected currency. Within my qry_costes I have all costs in local currency. I also have a second table RateToEUR with the conversion from several currencies to EURO, and a third one RateToUSD doing the same to USD. The idea is that, after using the combobox embedded in a form, field qry_costes.cost from qry_costes will be multiplied by the properly rate. I mean, if EURO is selected, and qry_costes.currency is BRL, for example, then qry_costes.cost will by multiplied by the value that belongs to BRL within RateToEUR. The problem is that I don't know how to distinguish between RateToEUR from RateToUSD. Is possible to use a IFF clause?
Thanks all for your help.
I've found that exRate table was wrong, but code is ok. Thanks anyway
Related
This is the screenshot of how the final output should look.
However, in the screenshot you will find that purchase total (calculated text label) is the sum total of the first order description Total (calculated at form level): Final Form view section display
The above screenshot result is the output of this formula
=[OrderDescription_tbl].[Form]![Total]
If I use this formula
=Sum([OrderDescription_tbl].[Form]![Total])
The output is #Error.
Troubleshooting I did,
I had created a grand total at the footer of the Subform using
the Sum function and visible parameter set to No and wanted to
reference the output to the Main form Purchase total. How to solve this problem?
However, in the screenshot you will see the number of boxes
count (Not calculated and is a table column), I used the same Sum()
function in the order_description subform. It gives the correct
output. Why is there a difference in output for the same function
one, against the Non-calculated table column and the other, a calculated form text label?
I have used this formula too
=IIf([OrderDescription_tbl].[Form]![Total]>0,Sum([OrderDescription_tbl].[Form]![Total]),0)
Output is still #Error
I have used an query which calculates sum total of each line item and tried to reference this query as
a)=Sum([Query1]![Expr1]) received #Error
b)[Query1]![Expr1] received #Name?
As an alternative to the DSum solution proposed by Kostas, you can use the following workaround:
in the footer of the subform, insert a textBox with the =Sum([Total]) formula, name the textBox BigTotal (or whatever you want)
in the main form, refer to that control: =mySubFormControl.Form!BigTotal
make the subform's footer hidden if you want.
If you have large data sets, this should be faster than the DSum. Also if the subform has an embedded query as its recordSource, you avoid the creation of a queryDef.
Try the DSum() function:
=DSum("[Total]",[OrderDescription_tbl].[Form].[RecordSource])
Thanks! I have been able to solve it using the existing structure only. In this regard I referenced Northwind database.Although,my database would have been more specific and different from Northwind,some aspects from Northwind did give me hints on what to change. The trick was - I had several lookups fixed on numerical columns like unit_rate(and this unit_rate referred a product portfolio table containing product offering of our company).Once, I removed the lookup aspect of these column values, #Error as well as Name? error were automatically resolved. I created a grand total with Visible parameter set to No inside the order description subform and referenced the output of this form to the grand_total text label in the outer form as seen in the screenshots shared.😀 Thank you for the support#Ren Kessler and I will share this is Stackoverflow too so that others can take advice from my case scenario. Ren Kessler I will use your method in some other way,may be in this development scenario but for some other context. I found it quite interesting and I havent tried it. Apart from my reply, I would like to quote you and your solution method too.Total_Calculation_subforminternal_view_Expression_builder_for_grandtotal_textlabel
This is the solution Given by Ren Kessler(Facebook group member):" I solved it in a very convoluted way. I hope someone has a better solution than mine.
I created a series of fields on my form (not fields in a table, but just on the form) that reference the fields on the subform. Then I performed all my math using these form fields. It was the easiest way I could find.
It seems clumsy, but works. As well, it made it easy to use these fields on a report (in my case, an invoice).
In previous versions I did not have to do this. I took a 2002 app where the math worked on the sub form, and used the exact same steps in 2016 and got #error, just like you. This system solved it, but it just doesn't seem right."
I have a report that shows an opening balance. If the balance is zero then I want to the number format #,0.00 to display as 0.00. However, if there is a credit then I want the number format #,0.00 C to display as, for example 123.45 c
I'm thinking it's some kind of Switch expression but for the life of me can't get it working.
Thanks in advance.
Set the format property to the expression below
="#,0.00;#,0.00c;0.00"
i was trying to create a money related app in which users can choose their currency. Mysql datatype i tried is decimal(19,4). Now the problem is few currencies need three precisions and some need two
Eg:
oman rial needs three precisions. ie 1000 baisa = 1 omani rial. Hence my customers may enter 6.783 omani rial.
Where as my US customers will need only 2 precisions as 100 cents = 1 dollar and they may enter 5.50.
When i insert these two entries to my database using decimal(19,4), it is saved as 6.7830 and 5.5000 respectively.
Now the real pain is when i need to display their entrys as i dont want to display that extra 0 in omani rial entry and that 00 in US dollar. I also tried float but last digit gets rounded off at times.
Is there any mysql data type in which i can save exact entry as it is without any rounding off or extra zeros? If there is no such entry, how can i make it ppssible?
You can use VARCHAR to store exact representations, but I don't recommend that because it takes more bytes to store a number as a string. And any arithmetic you do on the value will convert it to a number anyway.
I recommend you use DECIMAL(19,4), and then format the value in application code, to display it with the appropriate digits. Every programming language has some function like printf() that allows you to control the output formatting, regardless of the value stored.
I'll do my best to describe my problem. I'm modifying a report in Access 2010. I have a text box in my detail section that displays the weight of a pallet with boxes on it.
=[PalletWeight].
The PalletWeight field is generated from a SQL query that grabs this information from our database. As it so happens in the database that field appears like so:
100.000000000. I don't know the data type for that field in the database because looking isn't as simple as opening SQL Server, but =CDbl([PalletWeight]) does work so unless someone tells me they need to know I didn't obtain that information for this question.
The pallets are grouped by item. So item 1 might need to be carried on 3 pallets, item 2 might need 4, etc...
As mentioned earlier, I used CDbl on the textbox to convert the value to appear as 100.00 on the actual report.
I need to add a text box that calculates percentage. For each item, the total weight of the pallets needed per item is a certain percentage of the grand total weight of all pallets produced.
When I attempted do something like the following I get the #Type! error.
=Format([PalletWeight / Sum(PalletWeight) * 100, "Percentage")
I've also tried to refer to the text box by name (name reference) to perform operations on its value instead of the value contained in the text box.
=Format([TextBox1] / [Textbox2] * 100), "Percentage").
This report has various grouping sections. I've tried using hidden text boxes to hold the values I want to manipulate and referencing those but it seems as soon as I use arithmetic I get the #type!.
I'm using the expression builder in the properties Control Source section. Any help would be greatly appreciated.
You either need to modify your query to add another calculated field
say dblPalletWeight =CDbl([PalletWeight])
and then use that in your formula
=Format(dblPalletWeight / Sum(dblPalletWeight) * 100, "Percentage")
Or modify your formula to do the conversion on the fly
=Format(CDbl([PalletWeight]) / Sum(CDbl([PalletWeight])) * 100, "Percentage")
I am using Access 2010 to create a database of fish caught by local fishermen. I have a table with all the information about each fish caught (location, day, length, etc) and a form to add new records to that table. I am trying to automate as much of the data entry as possible because we have many interns that will be entering data throughout the summer. The more I can have the program do, the more I can limit mistakes in data entry.
I would like to store the length data in metric (mm), however most of the fishermen report the lengths of the fish they catch in inches. I don't care to have length twice in my database, one metric and one imperial.
Is there a way I can have a box on the form that someone can enter the length in inches and this value is converted to metric and used to fill in the length field on the table? The trick is that sometimes the fish length is reported in metric, so I need to be able to directly input metric into the form too.
I'm guessing this is either not possible or already somewhere & I am not using the right key words in my searches. I appreciate anyone who can point me in the right direction.
Thanks!
Here's one way to do it. It's similar to Scotch's, but with a few enhancements.
Have 2 textboxes. 1 each for millimeter & inch sizes.
The Milimeters textbox is bound to the table through the Control Source, so what is entered in there is what is saved in the database.
The Inches textbox is unbound. But what is entered into that textbox is converted and the new value is put into the Millimeter textbox. The code would look like this:
Private Sub txtSizeIn_AfterUpdate()
Me.txtSizeMM = Me.txtSizeIn * 25.4
End Sub
This way, the fisherman will have a choice on what measurement to use.
In the After Update for your control in which the measurement is entered, say the control is called Length.
You can change it in vba with this code.
Me.length = me.length * 25.4
This is one of many ways to do this