473,403 Members | 2,323 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,403 software developers and data experts.

Run code if a data field is empty

I have this code that will run as long as all the fields below have
data in them. How can I get the code to run if at least one field has
data in it.
strBCCEmail = "1" & [SupervisorFax] & "@faxmail.com; " &
[SupervisorEmail] & "; " & "1" & [HRContactFax] & "@faxmail.com; " &
[HRContactEmail]

Thanks

Dec 14 '06 #1
4 2176
What happens when one of the fields does not have data? What is the context
of your VBA? It appears you are setting a variable from something, which
could be Controls on a Form or Report, or Fields in the underlying Record
Source. What type of data are the Fields? You might use the NZ function if
you are having a problem with Nulls, but it may or may not yield a useful
result.

But, just as an item of information, the code will execute whether or not
there's data in the referenced items... it may encounter an error, or it
might even crash Access, but it will "run".

Larry Linson
Microsoft Access MVP

"mchlle" <mc****@austin.rr.comwrote in message
news:11*********************@73g2000cwn.googlegrou ps.com...
>I have this code that will run as long as all the fields below have
data in them. How can I get the code to run if at least one field has
data in it.
strBCCEmail = "1" & [SupervisorFax] & "@faxmail.com; " &
[SupervisorEmail] & "; " & "1" & [HRContactFax] & "@faxmail.com; " &
[HRContactEmail]

Thanks

Dec 14 '06 #2
I suppose you are correct it does run and it encounters an error:
Runtime 2295
Unknown message recipient(s); the message was not sent.

I'm trying to send out emails that include the supervisor's email and
fax number, HR's email and fax number of the student's record. I'm
trying to string all the email and fax number fields and put them in
the bcc field of an email message.

It works fine if all four fields have data in them. It opens an email
message from Outlook and inserts all the fields into the bcc field but
if I only have one email or fax number per say I get the above error
message.

Thanks

Dec 15 '06 #3
"mchlle" <mc****@austin.rr.comwrote
I suppose you are correct it does run and it encounters an error:
Runtime 2295
Unknown message recipient(s); the message was not sent.
I'll venture that not only does it run, it runs quite correctly. It is using
the fields to construct the address to which the information is to be sent,
and if any of them are "empty", "null", or "zero-length string", the
resultant address will not be properly filled in -- it will be incomplete.

It's not clear to me whether nothing is being sent to any addressee, or if
all but the improper address (the one for which the field was empty) were
sent. Access is not the problem, if indeed there is a problem -- it is your
mailing / faxing software.

But, you could fix the problem in Access with a little VBA code -- construct
each of the addresses separately, and only if all the parts are there,
concatenate the address to the others for insertion into the mail / fax
message.

Larry Linson
Microsoft Access MVP

Dec 15 '06 #4
rwr
mchlle wrote:
I have this code that will run as long as all the fields below have
data in them. How can I get the code to run if at least one field has
data in it.
strBCCEmail = "1" & [SupervisorFax] & "@faxmail.com; " &
[SupervisorEmail] & "; " & "1" & [HRContactFax] & "@faxmail.com; " &
[HRContactEmail]

Thanks
Look at the IsEmpty(), IsNull() and IsBlank() instructions.

The [SupervisorFax], [SupervisorEmail], [HRContactFax], and
[HRContactEmail] fields are the only variables or unknowns you have.
Everything else is a constants. So you could do something like:

If Not (IsNull([SupervisorFax]) or IsEmpty([SupervisorFax]) or _
IsBlank([SupervisorFax]) or [SupervisorFax]="" or _
[SupervisorFax]=" ") then
Supervisor Fax number is good
EndIf

This is just an example, you may not need to use all of these tests
to solve your problem. If any of the above tests return true, then
you cannot create a proper email address.

HTH,
Ron
Dec 17 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Randell D. | last post by:
Folks, Perhaps someone can figure this out - this is 'the process of my script' I have a form whereby I can add multiple contacts to a single address. There is only one...
22
by: Martin MOKREJ© | last post by:
Hi, I'm looking for some easy way to do something like include in c or PHP. Imagine I would like to have: cat somefile.py a = 222 b = 111 c = 9
6
by: binger | last post by:
Okay, Superbowl is only a few days away, but I thought it would be cool to set up an online registration for a football squares pool. My thoughts are to have people go into anywhere on the 10x10...
12
by: Ferdi Smit | last post by:
I wanted to provide a template class with an optional data member. The most natural way to do this was to implement a member for a given template parameter, and in the case of 'void', then not. ...
0
by: richardkreidl | last post by:
I have the following hash script that I use to compare two text files. 'Class Public Class FileComparison Public Class FileComparisonException Public Enum ExceptionType U 'Unknown A 'Add...
3
by: jmarr02s | last post by:
Hi, How do I replace with when the field is empty? Thanks! jmarr02s
3
by: josh.kuo | last post by:
Sorry about the subject, I can't think of a better one. I recently wrote some PHP classes that I think might be of interest to this group. Since I have been reaping the benefits of reading news...
3
by: | last post by:
I'm using the DataList and GridView controls, and I am trying to wrap my head around the problem of conditionally showing or hiding cells/cell content based on the presence or absence of DB data. I...
4
by: Debbiedo | last post by:
My software program outputs an XML Driving Directions file that I need to input into an Access table (although if need be I can import a dbf or xls) so that I can relate one of the fields...
1
by: sivakrishna546 | last post by:
using System; using System.Collections; using System.ComponentModel; using System.Security.Permissions; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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,...

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.