Hi All,
I'm trying my hardest to learn VBA but have run into a problem which
hopefully someone can guide me with.
Basically what I am trying to achieve is to get the database to check the
users Outlook Inbox every hour for the existence of a mail from a certain
address. If it finds one, it saves the attachment and then imports the
contents of the attachment. However, before the import takes place, the text
file is checked to make sure that certain criteria are met.
At a timer event, a Private Sub runs which during it's course ,calls 2 other
public subs. One of the public subs does a couple of checks to make sure
that the data is correct. If it finds that it is not, I want all the code to
stop. I tried this by using Exit Sub. This quits the Public sub but allows
the Private sub to continue. I need to stop the Private sub from running :o(
Can anyone offer any suggestions on how best to achieve this?
Many thanks,
Mark 4 8352
"Mark" <ma*********@ntlworld.com> wrote in message
news:ee***************@newsfe7-gui.ntli.net... Hi All, I'm trying my hardest to learn VBA but have run into a problem which hopefully someone can guide me with.
Basically what I am trying to achieve is to get the database to check the users Outlook Inbox every hour for the existence of a mail from a certain address. If it finds one, it saves the attachment and then imports the contents of the attachment. However, before the import takes place, the text file is checked to make sure that certain criteria are met.
At a timer event, a Private Sub runs which during it's course ,calls 2 other public subs. One of the public subs does a couple of checks to make sure that the data is correct. If it finds that it is not, I want all the code to stop. I tried this by using Exit Sub. This quits the Public sub but allows the Private sub to continue. I need to stop the Private sub from running :o(
Can anyone offer any suggestions on how best to achieve this?
One approach would be to have the "public" sub return a boolean value and
have an If ... Then clause in the "private" one to evaluate it along the
lines of:
Private Sub MyCode()
If SubPublic Then ' The public sub has returned "True"
Exit Sub
Else
Do other stuff
End If
End Sub
Pretty high level I know but I hope it helps.
Regards,
Keith. www.keithwilby.com
Hi Keith,
It took a bit of research to figure out how to return a Boolean but once
I'd cracked that, the If clause worked perfectly. Many thanks for pointing
me in the right direction.
Regards,
Mark
"Keith W" <he**@there.com> wrote in message
news:43**********@glkas0286.greenlnk.net... "Mark" <ma*********@ntlworld.com> wrote in message news:ee***************@newsfe7-gui.ntli.net... Hi All, I'm trying my hardest to learn VBA but have run into a problem which hopefully someone can guide me with.
Basically what I am trying to achieve is to get the database to check the users Outlook Inbox every hour for the existence of a mail from a certain address. If it finds one, it saves the attachment and then imports the contents of the attachment. However, before the import takes place, the text file is checked to make sure that certain criteria are met.
At a timer event, a Private Sub runs which during it's course ,calls 2 other public subs. One of the public subs does a couple of checks to make sure that the data is correct. If it finds that it is not, I want all the code to stop. I tried this by using Exit Sub. This quits the Public sub but allows the Private sub to continue. I need to stop the Private sub from running :o(
Can anyone offer any suggestions on how best to achieve this?
One approach would be to have the "public" sub return a boolean value and have an If ... Then clause in the "private" one to evaluate it along the lines of:
Private Sub MyCode()
If SubPublic Then ' The public sub has returned "True" Exit Sub Else Do other stuff End If
End Sub
Pretty high level I know but I hope it helps.
Regards, Keith. www.keithwilby.com
Keith W wrote: Private Sub MyCode()
If SubPublic Then ' The public sub has returned "True" Exit Sub Else Do other stuff End If
End Sub
I say, does a sub return a boolean of some sort? My approach would have
been the same except to have made the "SubPublic" a public function
returning some value (in this case a boolean).
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Tim Marshall wrote: Keith W wrote:
Private Sub MyCode()
If SubPublic Then ' The public sub has returned "True" Exit Sub Else Do other stuff End If
End Sub
I say, does a sub return a boolean of some sort? My approach would have been the same except to have made the "SubPublic" a public function returning some value (in this case a boolean).
I think the OP knew what I meant ;-) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Maxwell Hammer |
last post by:
An application I am developing executes many threads and then has a
"monitor" part that waits for certain events. One of these events causes
the application to have to shutdown. On shutdown the...
|
by: Guinness Mann |
last post by:
Pardon me if this is not the optimum newsgroup for this post, but it's
the only .NET newsgroup I read and I'm certain someone here can help me.
I have a C# program that checks for an error...
|
by: suri |
last post by:
Hello
I downloaded glibc and tried looking for the code that implements the
sine function
i couldnt find the file.
i went to the math directory and found math.h.. i guess that needs to be...
|
by: LP |
last post by:
Hi,
Considering code below. Will it make GC to actually collect. One application
creates new instances of a class from 3rd party assembly in a loop (it has
to). That class doesn't have .Dispose or...
|
by: Sandy |
last post by:
Hello -
I need either a cheap tool or code & DB that calculates, eg. within 50-mile
radius of a zip code.
Anyone have any suggestions?
--
Sandy
|
by: Scott McDaniel |
last post by:
I'm using Visual Studio 2005 with the .NET 2.0.50727 framework, and we're using the standard Datagrid control bound to a
SQL Server.
We have two groups of users - "full edit" users, and "view...
|
by: MLH |
last post by:
I have a form, frmUSPSReturnReceipts, with a control named
NotExpectingGreenTickets. The control's Exit event procedure
follows:
Private Sub NotExpectingGreenTickets_Exit(Cancel As Integer)
If...
|
by: Bhujanga |
last post by:
I have some reports whose purpose is to show whether any records currently meet certain criteria, so of course the report is based on a query where that criteria is defined. If there don't happen to...
|
by: rleepac |
last post by:
I have a form with a tabbed control on it. I am trying to set certain criteria for some of the tabs to show only when info from other fields meet criteria.
Specifically, I have two fields. Both...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |