473,792 Members | 2,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Nested If with Trim function in Code Builder

5 New Member
Hello Access experts,

I am just new in this field and struggling with my code. I have a nested IF and it works in query but not sure how to apply it in form. I am thinking of making an event expression under "After Update". The idea is to populate the Description field by concatenating other fields. Below is the code I did in query, all help is appreciated.

Description: IIf([Name 3] Is Not Null And [Width] Is Not Null,(Trim([Material] & " " & [Type] & " with " & [Name 1] & ", " & [Name 2] & " and " & [Name 3] & ". Approximately " & [Width] & "mm x " & [Height] & "mm.")),IIf ([Name 3] Is Not Null And [Width] Is Null,(Trim([Material] & " " & [Type] & " with " & [Name 1] & ", " & [Name 2] & " and " & [Name 3] & ".")),IIf([Name 2] Is Not Null And [Width] Is Not Null,(Trim([Material] & " " & [Type] & " with " & [Name 1] & " and " & [Name 2] & ". Approximately " & [Width] & "mm x " & [Height] & "mm.")),IIf ([Name 2] Is Not Null And [Width] Is Null,(Trim([Material] & " " & [Type] & " with " & [Name 1] & " and " & [Name 2] & ".")),IIf([Name 1] Is Not Null And [Width] Is Not Null,(Trim([Material] & " " & [Type] & " with " & [Name 1] & ". Approximately " & [Width] & "mm x " & [Height] & "mm.")),IIf ([Name 1] Is Not Null And [Width] Is Null,(Trim([Material] & " " & [Type] & " with " & [Name 1] & ".")),Trim([Material] & " " & [Type] & ".")))))))
Sep 5 '07 #1
2 2601
ADezii
8,834 Recognized Expert Expert
Hello Access experts,

I am just new in this field and struggling with my code. I have a nested IF and it works in query but not sure how to apply it in form. I am thinking of making an event expression under "After Update". The idea is to populate the Description field by concatenating other fields. Below is the code I did in query, all help is appreciated.

Description: IIf([Name 3] Is Not Null And [Width] Is Not Null,(Trim([Material] & " " & [Type] & " with " & [Name 1] & ", " & [Name 2] & " and " & [Name 3] & ". Approximately " & [Width] & "mm x " & [Height] & "mm.")),IIf ([Name 3] Is Not Null And [Width] Is Null,(Trim([Material] & " " & [Type] & " with " & [Name 1] & ", " & [Name 2] & " and " & [Name 3] & ".")),IIf([Name 2] Is Not Null And [Width] Is Not Null,(Trim([Material] & " " & [Type] & " with " & [Name 1] & " and " & [Name 2] & ". Approximately " & [Width] & "mm x " & [Height] & "mm.")),IIf ([Name 2] Is Not Null And [Width] Is Null,(Trim([Material] & " " & [Type] & " with " & [Name 1] & " and " & [Name 2] & ".")),IIf([Name 1] Is Not Null And [Width] Is Not Null,(Trim([Material] & " " & [Type] & " with " & [Name 1] & ". Approximately " & [Width] & "mm x " & [Height] & "mm.")),IIf ([Name 1] Is Not Null And [Width] Is Null,(Trim([Material] & " " & [Type] & " with " & [Name 1] & ".")),Trim([Material] & " " & [Type] & ".")))))))
You can replace the IIf() Functions with Nested If..Then..Else. .ElseIf..End If structures, something similar to the following:
Expand|Select|Wrap|Line Numbers
  1. If Not IsNull(Me![Name 3]) And Not IsNull(Me![Width]) Then
  2.   Me![Description] = Trim(Me![Material]) & " " & Me![Type] & " with " & Me![Name 1] & ", " & Me![Name 2] & _
  3.                      " and " & Me![Name 3] & ". Approximately" & Me![Width] & "mm x " & Me![Height] & "mm."
  4. Else
  5.   If Not IsNull(Me![Name 3] And IsNull(Me![Width]) Then
  6.     Me![Description] = Trim(Me![Material]) & " " & Me![Type] & " with " & Me![Name 1] & ", " & Me![Name 2] & _
  7.                        " and " & Me![Name 3] & "."
  8.   ElseIf Not IsNull(Me![Name 2]) And Not IsNull(Me![Width]) Then
  9.     Me![Description] = Trim(Me![Material]) & " " & Me![Type] & " with " & Me![Name 1] & " and " & Me![Name 2] & ". " & _
  10.                        "Approximately " Me![Width] & "mm x " & Me![Height] & "mm."
  11.   'Other Nested If/Else/ElseIf/End If structures where needed
  12.   End If
  13. End If
Sep 5 '07 #2
ADezii
8,834 Recognized Expert Expert
Hello Access experts,

I am just new in this field and struggling with my code. I have a nested IF and it works in query but not sure how to apply it in form. I am thinking of making an event expression under "After Update". The idea is to populate the Description field by concatenating other fields. Below is the code I did in query, all help is appreciated.

Description: IIf([Name 3] Is Not Null And [Width] Is Not Null,(Trim([Material] & " " & [Type] & " with " & [Name 1] & ", " & [Name 2] & " and " & [Name 3] & ". Approximately " & [Width] & "mm x " & [Height] & "mm.")),IIf ([Name 3] Is Not Null And [Width] Is Null,(Trim([Material] & " " & [Type] & " with " & [Name 1] & ", " & [Name 2] & " and " & [Name 3] & ".")),IIf([Name 2] Is Not Null And [Width] Is Not Null,(Trim([Material] & " " & [Type] & " with " & [Name 1] & " and " & [Name 2] & ". Approximately " & [Width] & "mm x " & [Height] & "mm.")),IIf ([Name 2] Is Not Null And [Width] Is Null,(Trim([Material] & " " & [Type] & " with " & [Name 1] & " and " & [Name 2] & ".")),IIf([Name 1] Is Not Null And [Width] Is Not Null,(Trim([Material] & " " & [Type] & " with " & [Name 1] & ". Approximately " & [Width] & "mm x " & [Height] & "mm.")),IIf ([Name 1] Is Not Null And [Width] Is Null,(Trim([Material] & " " & [Type] & " with " & [Name 1] & ".")),Trim([Material] & " " & [Type] & ".")))))))
You can replace the IIf() Functions with Nested If..Then..Else. .ElseIf..End If structures, something similar to the following:
Expand|Select|Wrap|Line Numbers
  1. If Not IsNull(Me![Name 3]) And Not IsNull(Me![Width]) Then
  2.   Me![Description] = Trim(Me![Material]) & " " & Me![Type] & " with " & Me![Name 1] & ", " & Me![Name 2] & _
  3.                      " and " & Me![Name 3] & ". Approximately" & Me![Width] & "mm x " & Me![Height] & "mm."
  4. Else
  5.   If Not IsNull(Me![Name 3] And IsNull(Me![Width]) Then
  6.     Me![Description] = Trim(Me![Material]) & " " & Me![Type] & " with " & Me![Name 1] & ", " & Me![Name 2] & _
  7.                        " and " & Me![Name 3] & "."
  8.   ElseIf Not IsNull(Me![Name 2]) And Not IsNull(Me![Width]) Then
  9.     Me![Description] = Trim(Me![Material]) & " " & Me![Type] & " with " & Me![Name 1] & " and " & Me![Name 2] & ". " & _
  10.                        "Approximately " Me![Width] & "mm x " & Me![Height] & "mm."
  11.   End If
  12.   'Other Nested If/Else/ElseIf/End If structures where needed
  13. End If
Sep 5 '07 #3

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

Similar topics

0
2804
by: mcp6453 | last post by:
I am trying to use Jack's FormMail script (http://www.dtheatre.com/scripts/formmail). Since I'm brand new at PHP and not very good at HTML, I have an easy question, which I will narrow down. When the email arrives, it has this information: v_firstname: asdf v_lastname: asdf b_email: asdf@bellsouth.net v_phone: asdf v_cellphone: asdf
3
6472
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I COULD be wrong... :) I've tried the access group...twice...and all I get is "Access doesn't like ".", which I know, or that my query names are too long, as there's a limit to the length of the SQL statement(s). But this works when I don't try to...
2
5111
by: José Joye | last post by:
Hello, I was wondering if there is a method that exists to replace multi-spaces within a string with single-space. eg: "12 3 4 56" --> "12 3 4 56" I think this could be done by looking at each char within a loop and copying the char to a stringBuilder instance if current and previous char are not spaces...
2
3403
by: Goethals Frederik | last post by:
hi, I have a little problem with the function "Page.GetPostBackClientHyperlink". First some description of my page: It is a simple testpage for testing "selecting a row af the datagrid by clicking on the whole row". After some googling I thought I found a solution (see code below) I have a datagrid with 1 Select-column (via the property-building in VS.NET) and some auto-generated colums with data. The "Select-column" is the first column...
2
7238
by: pradeep.thekkottil | last post by:
I'm setting up an auction website using PHP and MySQL. There in the section where logged in members can put up new auction in a form, I want to run a form validation where I used if else statements to check the fileds filled. In the form page there are two radio buttons - fixed and auction - (only one can be chosen) and depend upon which one is chosen some text should be inserted in the text fields. For that I'm using a validation where...
0
1550
by: minhtran | last post by:
Hi everyone I have a problem when I want to edit the value from nested dropdownlist in Gridview, Please, anyone can help me to solve this problem, a great appreciation from me in advance. here is my sample code ASP.NET with VB.NET Protected Sub gridview5_rowdatabound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView5.RowDataBound Dim Columns() As String Dim myDataset As New...
3
2653
by: RobertTheProgrammer | last post by:
Hi folks, I've got another problem. Basically, I'm trying to use a nested GridView, however the nexted GridView displays no values (even though in debug I'm getting valid values into my DataSet. It's probably a binding issue somewhere, but I'm not sure where. Here's the ASP (slightly edited to remove verbosity): <asp:GridView ID="GridViewMain" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" ...
3
2213
by: ibeehbk | last post by:
Hi. I have a form made in xhtml. I test via vbscript to make sure none of the fields are empty and properly formatted (ie email). All the regular fields work. However, I have two drop down menus that are SELECT elements (javascript-- one named arrivalcity and one named returncity). Basically they ask for a departure and return city and another menu appears with options based on that city. I can't seem to get the input from these fields in the...
5
13383
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL http://mghospedagem.com/images/controlpanel.jpg instead of http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg As u see, there's the website URL before the image URL.
0
9518
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10430
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10211
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10159
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,...
0
9033
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, 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...
0
5436
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...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3719
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2917
bsmnconsultancy
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.