473,414 Members | 1,937 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,414 software developers and data experts.

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

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 2266
ADezii
8,834 Expert 8TB
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 Expert 2GB
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
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 Expert 2GB
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 Expert 8TB
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 Expert 2GB
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 Expert 8TB
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 Expert 2GB
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 Expert 2GB
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
ADezii
8,834 Expert 8TB
Did you suffer hard ?? :))))))))))
Not until recently, when I became involved with TheScripts Forum. (LOL).
Sep 2 '07 #11
Thank you so much! I added a little more code to handle a last condition, and here is the final code that works!

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
With Me
If IsNull(.[Cell]) And (Not IsNull(.[eMailAddress])) Then
.[CellLabel].Visible = False
.[eMailLabel].Visible = True
.[eMailAddress].Top = .[Cell].Tag
.[eMailLabel].Top = .[Cell].Tag
ElseIf IsNull(.[Cell]) And (IsNull(.[eMailAddress])) Then
.[CellLabel].Visible = False
.[eMailLabel].Visible = False
Else
.[CellLabel].Visible = True
.[eMailLabel].Visible = True
.[eMailAddress].Top = .[eMailLabel].Tag
.[eMailLabel].Top = .[eMailLabel].Tag
End If
End With
End Sub

Private Sub Report_Open(Cancel As Integer)
With Me
.[Cell].Tag = .[Cell].Top
.[eMailLabel].Tag = .[eMailLabel].Top
End With
End Sub
Thanks again! You saved me! Happy Labor Day!
Sep 3 '07 #12
FishVal
2,653 Expert 2GB
You are welcome. Good luck.
Sep 3 '07 #13

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

Similar topics

11
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...
7
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...
81
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...
3
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...
8
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...
2
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...
2
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...
5
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...
4
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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.