473,405 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Calculte Depends on the Type i choose in the combobox

Hi,
i have a form with SubForm and the view is DataSheet.

inside i have 4 TextBox and 1 combobox

1. Amount-Textbox
2. Weight - Textbox
3. Price$ - TextBox
3. Calculte Type- Combobox
4. Total$- Calculeted Textbox

the combobox have 2 options
1. Weight
2. Amount

i want to make the Total$ Textfield to calculte Depends on the Type i choose in the combo box.

if i choose Weight he will do : Price$ * Weight
if i choose Amount he will do : Price$ * Amount

can it be done?
Thank you!
Jan 27 '17 #1

✓ answered by Seth Schrock

I would use the Switch() function because it makes it so that you have three tests without nesting functions. So your formula would be something like
Expand|Select|Wrap|Line Numbers
  1. Switch([Calculte Type] = 'Weight', [Weight] * [Price$], [Calculte Type] = 'Amount', [Amount] * [Price$], [Calculte Type] Is Null, 0)
Now you can put this as the control source of your Total$ textbox (with a preceding equals sign) or as a calculated field in a query set as the record source for your subform.

1 704
Seth Schrock
2,965 Expert 2GB
I would use the Switch() function because it makes it so that you have three tests without nesting functions. So your formula would be something like
Expand|Select|Wrap|Line Numbers
  1. Switch([Calculte Type] = 'Weight', [Weight] * [Price$], [Calculte Type] = 'Amount', [Amount] * [Price$], [Calculte Type] Is Null, 0)
Now you can put this as the control source of your Total$ textbox (with a preceding equals sign) or as a calculated field in a query set as the record source for your subform.
Jan 27 '17 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: DBQueen | last post by:
Hi - In my A2K database, I have a form with 2 Unbound Comboboxes, both of which open up forms to a particular record. One of these comboboxes works perfectly. For some reason the 2nd one WILL...
4
by: VMI | last post by:
How can I create a comboBox that will display the first item that begins with the group of letters I type? In my current combobox (it's a DropDownList), if I press the letters "S" and "A"...
1
by: developers | last post by:
I know that some developers would like a type-ahead combobox in VB.NET. This type of combobox would automatically select the next available match as the user types in a selection. I've written...
5
by: Gil | last post by:
Is there a way to tell if a combbox is in dropdown mode. I tried and if statement combobox.dropdown = true but i get an error. dropwndown function doesnt store if its true or false what i am...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
0
by: Rain County | last post by:
I want to *programmatically* set the cell type of a dataGridView column to be a dropdown combobox. Can anyone tell me how? Thanks Phil
7
by: Harris | last post by:
Dear all, I have the following codes: ====== public enum Enum_Value { Value0 = 0, Value1 = 10,
2
by: Paul | last post by:
VB.NET 2003. I am loading a dialog box form with a ComboBox. I'm using a DropDownStyle of "DropDown" rather than "DropDownList". I want them to be able to type in it fill in as they type. The...
1
by: Uli Netzer | last post by:
between Dim strXYZ() as String and Dim strXYZ as String() It doesn't seem to make a difference in the way I use the variable. Another problem I have. I load three variables with 3 values...
1
by: accessbeginerry | last post by:
I have two comboboxes which are generated by queries from mysql. When user choose value in first combobox i need to display second combobox, but if nothing is choosen second combox should not be...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.