473,569 Members | 2,793 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Moving" a line in a Report based on 2 conditions

3 New Member
I am developing a simple report that lists Name, Address, Home Phone, Cell Phone and eMail address. The format is like the “Address Cards” format in Outlook (see below). Many of the people on the roster have no cell phone and/or eMailAddress. I used a text box for the “label” for the cell phone and email fields. I used the following for the cell phone “label”: =IIf(IsNull([Cell])," ","Cell Phone:") so that if there is no cell phone number, the “label” doesn’t print. I have similar code in the email field. If both cell phone and email fields are null, it works great

The problem arises when there is an email address (bottom line) but no cell phone number (2nd last line). I end up with a blank line separating the email address from the rest of the lines. Is there a way that I can code the email address “label’ (text box) to say that if the cell phone field is null, but the email isn’t, to move the email address up to where the cell phone entry would have been? I thought maybe I could use the “Top” property, but I can’t find in any of the help how to test for 2 conditions. I couldn’t figure out a way to do it via nested Iifs either.

I would really appreciate some help. Thanks!

Name
Address
City, State, Zip
Home Phone
Cell Phone
eMailAddress
Sep 1 '07 #1
12 2276
ADezii
8,834 Recognized Expert Expert
I am developing a simple report that lists Name, Address, Home Phone, Cell Phone and eMail address. The format is like the “Address Cards” format in Outlook (see below). Many of the people on the roster have no cell phone and/or eMailAddress. I used a text box for the “label” for the cell phone and email fields. I used the following for the cell phone “label”: =IIf(IsNull([Cell])," ","Cell Phone:") so that if there is no cell phone number, the “label” doesn’t print. I have similar code in the email field. If both cell phone and email fields are null, it works great

The problem arises when there is an email address (bottom line) but no cell phone number (2nd last line). I end up with a blank line separating the email address from the rest of the lines. Is there a way that I can code the email address “label’ (text box) to say that if the cell phone field is null, but the email isn’t, to move the email address up to where the cell phone entry would have been? I thought maybe I could use the “Top” property, but I can’t find in any of the help how to test for 2 conditions. I couldn’t figure out a way to do it via nested Iifs either.

I would really appreciate some help. Thanks!

Name
Address
City, State, Zip
Home Phone
Cell Phone
eMailAddress
In order to do what you are requesting, you would have to dynamically change the ControlSource relating to the [Cell Phone] Field to that of the [email] Field when the condition is met (IsNull([Cell Phone]) And Not IsNull([email])). This cannot be done in either the Format() or Print() Events of the Detail Section.
Sep 2 '07 #2
FishVal
2,653 Recognized Expert Specialist
Hi, there.

Try smthng like this

Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  2.     With Me
  3.         If IsNull(.[Cell Phone]) And (Not IsNull(.[eMailAddress])) Then
  4.             .[Cell Phone Label].Visible = False
  5.             .[eMailAddress].Top = .[Cell Phone].Top
  6.             .[eMailAddress Label].Top = .[Cell Phone Label].Top
  7.         End If
  8.     End With
  9. End Sub
  10.  
Good luck.
Sep 2 '07 #3
pmonreal
3 New Member
Wow, thanks for the quick response! The code you provided worked when there was an email address, but no cell number. However, when there is both a cell number and email address, the email address overlays the cell number.
Sep 2 '07 #4
FishVal
2,653 Recognized Expert Specialist
Wow, thanks for the quick response! The code you provided worked when there was an email address, but no cell number. However, when there is both a cell number and email address, the email address overlays the cell number.
Ok.

You just need to restore the controls position/visibility. For this purpose you need to store original eMail controls position. You can use store them in global variables or in the controls Tag property.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  2.     With Me
  3.         If IsNull(.[Cell Phone]) And (Not IsNull(.[eMailAddress])) Then
  4.             .[Cell Phone Label].Visible = False
  5.             .[eMailAddress].Top = .[Cell Phone].Tag
  6.             .[eMailAddress Label].Top = .[Cell Phone Label].Tag
  7.         Else
  8.             .[Cell Phone Label].Visible = True
  9.             .[eMailAddress].Top = .[eMailAddress].Tag
  10.             .[eMailAddress Label].Top = .[eMailAddress].Tag
  11.         End If
  12.     End With
  13. End Sub
  14.  
  15. Private Sub Report_Open(Cancel As Integer)
  16.     With Me
  17.         .[Cell Phone].Tag = .[Cell Phone].Top
  18.         .[eMailAddress Label].Tag = .[eMailAddress Label].Top
  19.     End With
  20. End Sub
  21.  
Sep 2 '07 #5
ADezii
8,834 Recognized Expert Expert
Hi, there.

Try smthng like this

Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  2.     With Me
  3.         If IsNull(.[Cell Phone]) And (Not IsNull(.[eMailAddress])) Then
  4.             .[Cell Phone Label].Visible = False
  5.             .[eMailAddress].Top = .[Cell Phone].Top
  6.             .[eMailAddress Label].Top = .[Cell Phone Label].Top
  7.         End If
  8.     End With
  9. End Sub
  10.  
Good luck.
Nice solution, FishVal!
Sep 2 '07 #6
FishVal
2,653 Recognized Expert Specialist
Nice solution, FishVal!
Thanks, ADezii.

Actually this looks like stub so far.

I thought about more general and reusable code but it seems to me that amount of code and execution time ;) grow exponentially approaching to more or less universal solution.

I think the really nice solution here is to reorganize table structure.
Really, how many people do you know that have only one e-mail or one phone number. :)

Regards

Fish
Sep 2 '07 #7
ADezii
8,834 Recognized Expert Expert
Thanks, ADezii.

Actually this looks like stub so far.

I thought about more general and reusable code but it seems to me that amount of code and execution time ;) grow exponentially approaching to more or less universal solution.

I think the really nice solution here is to reorganize table structure.
Really, how many people do you know that have only one e-mail or one phone number. :)

Regards

Fish
Really, how many people do you know that have only one e-mail or one phone number. :)
Believe it or not, when I was young there was no such thing as an E-Mail Address and a cell phone was considered a luxury! LOL.
Sep 2 '07 #8
FishVal
2,653 Recognized Expert Specialist
Ok.

You just need to restore the controls position/visibility. For this purpose you need to store original eMail controls position. You can use store them in global variables or in the controls Tag property.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  2.     With Me
  3.         If IsNull(.[Cell Phone]) And (Not IsNull(.[eMailAddress])) Then
  4.             .[Cell Phone Label].Visible = False
  5.             .[eMailAddress].Top = .[Cell Phone].Tag
  6.             .[eMailAddress Label].Top = .[Cell Phone Label].Tag
  7.         Else
  8.             .[Cell Phone Label].Visible = True
  9.             .[eMailAddress].Top = .[eMailAddress].Tag
  10.             .[eMailAddress Label].Top = .[eMailAddress].Tag
  11.         End If
  12.     End With
  13. End Sub
  14.  
  15. Private Sub Report_Open(Cancel As Integer)
  16.     With Me
  17.         .[Cell Phone].Tag = .[Cell Phone].Top
  18.         .[eMailAddress Label].Tag = .[eMailAddress Label].Top
  19.     End With
  20. End Sub
  21.  

Sorry. There are typos in a code.
Actually it should look like
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  2.     With Me
  3.          If IsNull(.[Cell Phone]) And (Not IsNull(.[eMailAddress])) Then
  4.             .[Cell Phone Label].Visible = False
  5.             .[eMailAddress].Top = .[Cell Phone].Tag
  6.             .[eMailAddress Label].Top = .[Cell Phone].Tag
  7.         Else
  8.             .[Cell Phone Label].Visible = True
  9.             .[eMailAddress].Top = .[eMailAddress].Tag
  10.             .[eMailAddress Label].Top = .[eMailAddress].Tag
  11.         End If
  12.     End With
  13. End Sub
  14.  
  15. Private Sub Report_Open(Cancel As Integer)
  16.     With Me
  17.         .[Cell Phone].Tag = .[Cell Phone].Top
  18.         .[eMailAddress].Tag = .[eMailAddress].Top
  19.     End With
  20. End Sub
  21.  
Sep 2 '07 #9
FishVal
2,653 Recognized Expert Specialist
Believe it or not, when I was young there was no such thing as an E-Mail Address and a cell phone was considered a luxury! LOL.
Did you suffer hard ?? :))))))))))
Sep 2 '07 #10

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

Similar topics

11
24058
by: Matt Kruse | last post by:
This is a common requirement - "freeze panes" in a table, so that some header rows and some columns on the left are frozen while the body content scrolls. This makes large tables more usable on screen. There are a number of solutions available. For example, http://www.litotes.demon.co.uk/example_scripts/tableScroll.html I'm just wondering...
7
3563
by: Ellen Manning | last post by:
I've got an A2K report showing students and their costs. Student info is in the main report and costs are in a subreport for each student. The user inputs the program desired then only those students in that program are printed. I want the subreports headings to print only for the first student on the page. Is there a way to suppress...
81
7238
by: Matt | last post by:
I have 2 questions: 1. strlen returns an unsigned (size_t) quantity. Why is an unsigned value more approprate than a signed value? Why is unsighned value less appropriate? 2. Would there be any advantage in having strcat and strcpy return a pointer to the "end" of the destination string rather than returning a
3
1336
by: OJ | last post by:
It's easy to control one ball (a graphic) to move and bounce inside a square. But I don't know how to create and control a large number of balls (10 or 100) and count how many times they hit a wall of the square. Anyone can help?? I have little experience in VB.net. Thanks in advance. OJ
8
10983
by: MikeJ | last post by:
In my office, we have workstations with standard Win 2000 images (OS plus standard apps like Office, etc.) as developers, we then install our development tools on top of those images. other developers in my office have installed VS8 and use it with no problems. however, on a new workstation that I recently got, I have installed VS8, and get...
2
2042
by: Ralf Kaiser | last post by:
Hi, is it possible to define another place where the "Temporary ASP.NET Files" are stored? I do not want to have them on my system partition because i have a separate partition for all the temporary stuff on a separate physical drive. Is there a registry entry that defines the place for that folder?
2
2859
by: Paul | last post by:
I am moving an existing app written years ago to a new server. It uses Sigma Template 1.3 and Quickform 1.1.1 and PEAR.php,v 1.1.1.1 2004/02/16 The directory structure is like this: /site /site/html/Pear.php /site/html/Sigma.php /site/html/Common.php /site/html/Quickform.php /site/html/Quickform/
5
2578
by: Gianni Mariani | last post by:
I'm hoping someone can tell me why using member address of works and why using the dot operator does not in the code below. The code below uses the template function resolution mechanism to determine wether a class contains a member. My understanding is that if a template function has an error during resolution of the function types, it is...
4
5647
by: Micheal | last post by:
Greetings Access Group, Being relatively new to Access, I try to work through problems on my own and have been very successful, although I have a conundrum that I have been working on for two days (total 10 hours) and I have yet to resolve it. please excuse me for my lack of terminology, I will try to provide you with the best of information. ...
0
7695
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, 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...
0
7612
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...
0
7922
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. ...
0
8119
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...
0
6281
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...
0
3653
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...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
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
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.