473,732 Members | 2,207 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Control Source IIF function

107 New Member
I have 4 controls, 3 text and 1 combo:
txtNumber1, txtNumber2, cboCalcOption, txtSum.
cboCaclOption has two possible value: "calculated " and "stated".

txtSum in the control source has the following formula:
Expand|Select|Wrap|Line Numbers
  1. IIF(cboCalcOption="calculated"; txtNumber1+txtNumber2; null)
If the cboCalcOption is "stated" I need to allow user to input some number in txtSum control, else it would be calculated.
The problem is that with this function (or with control source properties) user is not allowed to enter anything in the text control.
So, instead of null in the function I should somehow put the "user input".

Thank you!
Sep 13 '10 #1
4 3845
107 New Member
Until waiting for reply to see if it's possible to do this directly by using Control Properties, I solved it by using VBA. Although, I'm still waiting to see if somebody knows if it can be done by using Control Properties. However, I have another question (I'm quite curious guy :-) It's about good coding practice.

On txtNumber1, txtNumber2, cboCalcOption I have put AfterUpdate event which calls CalculatedField s sub.

In CalculatedField s sub are calculations for all 15 cases same like this, that I have on form.
So if I put something in txtNumber1 it will also check cboCalcOption2 and txtNumber3 and txtNumber4, and also other fields 10-15 times like that.

I was wondering is it better to make multiple subs seperating each calculation.
So, for the first occurrence I would call CalculateField1 with only one formula, for the second I would call CalculateField2 with other formula and controls just regarding that field, and so on...

Does it make any difference or maybe with computer speed we have today and this type of small programs it's unnoticeable?

Sep 13 '10 #2
255 Contributor
I'll just reply to the question you are curious of.

If you want to prevent checking something that needs to repeat the same things for 15 times, just because it has different field name. You can consider putting parameters in the sub. Such as this one placed in the module.
Expand|Select|Wrap|Line Numbers
  1. Public Sub FormatTextbox(ByRef pMyTextBox as Control)
  2.     With pMyTextBox
  3.         .BackColor = 0
  4.     End With
  5. End Sub
Sep 14 '10 #3
107 New Member
Ah, great!
So, for example, I would call sub like this after update of txtNumber1 --> Call SubName (txtSum1), and after update of txtNumber5 (second formula) --> Call SubName (txtSum2) ?
Sep 14 '10 #4
255 Contributor
Yes, as long as you are putting the things you need to the right variables that calculate the sum. Give a try and post the code if you have trouble.
Sep 16 '10 #5

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

Similar topics

by: Sharon | last post by:
I've had an Access 2000 app running successfully for many months on both Windows XP and Windows 2000. Recently when my Windows 2000 users call a particular report, they get first a dialog requesting a "Replace" parameter. If the user clicks OK, the report opens, but only displays #Error. When the user tries to close the report, he is next presented with the choice of halting the code in break mode or not. Regardless of his choice, the app...
by: Mark Lees | last post by:
I've created some fields that calculate future dates. The way they are set up they do not save to a table. This is the expression I used (=DateSerial(Year(),Month()+6,Day(). I placed it in the Control Source property. I want to save them to a table so I can use them on a report. So the 2 questions are: 1. How do you use a calculated field that doesn't save to a table in a report?
by: Cro | last post by:
Hello Access Developers, I'd like to know if it is possible to perform a count in an expression that defines a control source. My report is based on a query. In my report, I want a text box to display the number of times a certain value appears in a certain field (i.e. perform a ‘count'). I will be doing this for many values in many fields so do not wish to have scores of queries to build my report.
by: Bob | last post by:
I've got a bound report with a query as the record source. I'm adding a total to the footer and have inserted a text box to display it. I'm attempting to set the control source of the text box to a different sum aggregate query using the expression builder. When I select the query and it's single field, single row field it inserts the following in the control source box for the text box. =! I've tested the query (...
by: VivN | last post by:
I want to use an expression as the control source for a text box in a report (Access 2000). Whilst I have sucessfully used these simple ones =TimeToSingle(TotalHours(,)) =TimeToSingle(BHolHours(,,)) I get problems when I include a text parameter Scale (control just displays #error)
by: ChasW | last post by:
This should be most simple to do, and I am doing it elsewhere in the very same form, but for some reason it is not working in this case. My form uses a query as its Record Source. In the form view, I simply want to append some text to the view of this field in the form using the control source. The field name is: artist. This works fine for the control source: artist
by: Anja | last post by:
Hi everyone, I am trying to use the expression builder to create input to a control in an Access report. I have a table called Records and I want to select the minimum date for a record where the student = studentID.. The sql is pretty simple: "Select MIN(RecDate) from records_T where studentID = 1".
by: colin spalding | last post by:
Access 2003 I subform which lists financial transactions for a client in the main form, which i total in a textbox named "txtTotalPremium" in the subform footer with the Control Source "=Sum()"; without quotations of course. This works fine until the subform has no records to return in which case textbox is blank. That would be fine except I need to use the figure in another text box on the main form as part of another calculation. I...
by: beacon | last post by:
Hi everybody, Using Access 2003. I'm trying to dynamically set the record source for the current form and set the control source for a text box to input data to one of three tables. I have a form (frmAddNewUser) that will add users to one of three separate tables (tblDefsAFP, tblDefsMSU, tblDefsWF) based on the selection of an option button from an option group on the same form. I have a textbox (txtNewUser) that accepts the name of...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.