I am having trouble trying to create an expression that will give me a total based on two values in two different text boxes.
I created a form that has a text box called Niin, textbox called variance, textbox called price and textbox called Total.
I also have a table called NIIN_PRICE that has a NIIN column and a price column next to the associated Niin.
The result i am seeking is:
Have the value entered in textbox Niin lookup the corresponding value in Table NIIN_PRICE WHICH will then output the price into the Price textbox.
I will then want the total textbox to be an expression by multiplying the value in variance textbox with the value in price textbox and get the total of both numbers.
Example:
I type 1234 in NIIN textbox in my form,
1234 is searched in the NIIN_PRICE table and returns the value of .25. .25 is added to the price textbox as an output.
i then type 4 in the variance textbox which will update my value in the total textbox to 1 (.25 from the price pull Multiplied by 4 from my variance input).
Is this request possible? Thank you for the help.
theForm might look like this>>
tbxNIIN tbxPrice tbxVariance tbxTotal
on tbxNIIN event tab add AfterUpdate sub
that reads the NIIN_PRICE table and copies the value to tbxPrice
and then clears tbxVariance and tbxTotal
and sets cursor to tbxVariance.
On tbxVariance event tab add AfterUpdate sub
that multiplies the two and puts the result in tbxTotal
Related
I have a Form the fields are UPC, PurDate and Price.
The Price is controlled by a Dlookup to get the most recent price from the Price Table. It works by the user scanning the barcode of the product that fills the UPC field and the Price is automatically filled. This works good so far.
The problem is that some products do not have barcodes so I want to be able to manually fill the price for that item. Is there anyway to 'override' the Dlookup function or use some vba code to fill the Price field with user input?
Or maybe setup a UPC code eg. 0001 and when that code is selected the user can enter a price?
A control with an expression in ControlSource does not allow edit by user. Instead, use code (macro or VBA) to lookup price and populate field. Bind textbox to field. Now user can type over value retrieved. The real trick is figuring out what event to put code into.
I have a form called ProductionReportLandscape that has a table called ProductMasterData set as its record source.
There is text box control called CartonDateFormat (which gets its value from the ProductMasterData table) as well as an unbound text box control on ProductionReportLandscape.
Also in the database is a second table called DateCodes. Every record in the DateCodes table has a field called OutputDateCode. CartonDateFormat is a numeric value and can be any number 1-36.
I am trying to get the unbound text box control to return the value from OutputDateCode that corresponds to CartonDateFormat for each record.
For example, if CartonDateFormat is 13, then I would like the text box control to display the OutputDateCode from record 13 of the DateCodes table. If CartonDateCode is 14, then I want the text box to display OutputDateCode from record 14, etc for every number 1-36.
I have built a DLookup expression the control source property for the unbound text box, but it always returns the OutputDateCode from the first record regardless of what record is selected.
I cannot figure out how to change the expression in order to achieve the desired result. Any ideas?
=DLookUp("OutputDateCode","DateCodes","[CartonDateFormat] =" & [CartonDateFormat])
You reference names CartonDateFormat and CartonDateCode. You indicate CartonDateFormat is a textbox but not what CartonDateCode is.
Unless DateCodes has field CartonDateFormat with carton codes, DLookup cannot find match.
The DLookup needs to use name of field in DateCodes table that has carton codes. If that is CartonDateCode, then change DLookup to:
=DLookUp("OutputDateCode","DateCodes","[CartonDateCode] =" & [CartonDateFormat])
i have following table in access and i want that when the user click on the next record it should show the max value of digital_num based on the type for example:
when the form show the column type = "Petrol" another textbox that i added in the name of "text14" which has dlookup with max function it should show the value 200 in there not the 100 because i added max function.
ID Type Digital_Num
1 Petrol 100
2 Gas 50
3 Supper 150
4 Petrol 200
5 Gas 50
6 Supper 200
i added a textbox in the form in the name of "text14" besides the textboxes which automatically created for ID, Type, Digital_Num.
and i added the below Dlookup code to its control source
=DLookUp(Max("[Digital_Num]"),"table","[type] =" & '[Form].[type]')
when i switch my form to layout view it keeps showing 200 number in the text14 textbox which is the maximum value in the table it does not change even i press the next record
however it should show the max value of that type based when i click on the next record.
it may be more suitable to create an Aggregate Query to find the Max. Then do the LookUp of that query.
this is easier to test/debug then nesting the lookup and the max functionality in the same task
My simple form
Here is my simple purchase order form.
The form based on 2 tables. One named POMaster (data being POID and PODate) and the other one named Items(data being What you see plus a type called POIDno which is linked to the POID field to store items by POID)
How do I get Text10 to equal the sum of ItemTotal Column (By POID ofcourse) and if possible How do I get this value to store in a (hopefully) new data field in POMaster I would name POTotal?
Put a hidden total text box on the sub form and set your text box to the value of the hidden control.
You shouldn't store the value in the header as it can always be calculated.
However if you are storing it, you would have to determine a specific point in your process and ideally make sure no more updates can be made to the order lines, as that would mean having to re-calculate your stored value.
I have a code table that is a used in a combobox. It has an attribute on each code called "isActive" which has a value of "Y" or "N". The code table combobox is used to classify transaction data on the Orders table. For example:
ID Code isActive
-- ---------- --------
1 Repeat Y
2 New Y
3 Discount N
I want the list of items to include items that are no longer active (isActive="N") so the text can be displayed if someone looks at an old record that used a code that is no longer active. For example if an Order from last year was classified as "Discount" I want that to show when they look at the order.
However, I want the drop-down list for new orders NOT to display codes that are no longer active, since they only clutter the display. If the drop down only includes the codes where isActive="Y", then the order from last year with the code of "Discount" shows up blank.
How can I get the best of both worlds here?
If you don't have a particular row visible in the combo list, the combo won't display the text corresponding to the combo's value - no exceptions.
However...
If you sort the isActive = "N" entries to the bottom, then sort by ID or Code as usual, then the inactive entries won't clutter the list (as much), but will still display correctly. This is most easily done with a query bound to the combo's recordsource.
You can also display the isActive column so the users will know what they can and can't select, and prevent selection of isActive = "N" entries in the combo's BeforeUpdate event.