473,796 Members | 2,632 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Wanting to give users 3 options

All,
I have a procedure which checks the users Outlook Inbox for the
existance of an email from a specific address. If one is found, a question
is asked to the user asking if they wish to allow the database to save the
attachment and import the data. The reason for this is that the network is
extremely slow and the import takes several minutes to complete. During the
import, the database looks as though it is not responding. Giving them the
option to cancel the import stops them being interrupted whilst working.

My problem is that I wish to give the users another option which if they
select it, will import however many mails exist in their Inbox without
prompting them each time it finds a specific mail. This would be the case if
they do not intend to use the database for some time.

I'm a Newbie at VBA so forgive me if it's messy :o(

My code is as follows:

Public Sub CheckInbox(Save Path As String, StatusPart As Integer)
On Error GoTo AutoImportError
Dim mliNew As MailItem
Dim Ns As NameSpace
Dim oOutlook As Outlook.Applica tion
Dim QuestionAuto As String

Set oOutlook = New Outlook.Applica tion
Set Ns = oOutlook.GetNam espace("MAPI")
Set mfrInbox = Ns.GetDefaultFo lder(olFolderIn box)
With mfrInbox
Forms!frm_switc hboard!txt_Inbo xCount = .Items.Count
DoEvents

If .Items.Count = 0 Then 'No mails in Inbox
Forms!frm_switc hboard!txt_Inbo xCount = .Items.Count
Exit Sub 'Quit the routine if no mails exist
Else
.Items.Sort "Received", True
'Go through every email in the Inbox
For Each mliNew In .Items

If mliNew.SenderNa me = "AS400 George" Then 'Mail is one
we're looking for

'A mail is found, check with the user if they want to import it!!!!
QuestionAuto = MsgBox("Intake Manager has found an email in your Inbox which
it needs to import!" & vbNewLine & _
"The database will try now attempt to import the file" & vbCrLf
& vbCrLf & "This may cause the database to stop responding for several
minutes." & vbNewLine & _
"Do you want it to continue?", vbYesNo + vbQuestion, "Import
Check")

If QuestionAuto = vbNo Then
ImportTimer = 0 'Reset the timer
Exit Sub
End If
mliNew.Attachme nts.Item(1).Sav eAsFile SavePath 'Save the
attachment
ImportRatio

If Not IsNull(DLookup( "psku", "tbl_tmp_ratio" )) Then
MsgBox "During the Auto Import proceedure, a ratio
sku was found in the text file" & vbCrLf & _
"that doesn't exist in the database!" & vbCrLf & _
"Please update the ratio sku information now!!" &
vbCrLf & vbCrLf & _
"The database will attempt the import again within
the hour", vbCritical, "New Ratio Sku"

DoCmd.SetWarnin gs False
DoCmd.RunSQL "delete * from tbl_tmp_ratio;" 'Clear the temp ratio
table
DoCmd.SetWarnin gs True

Exit Sub
End If

ImportNewDay 'Run the Import proceedure
mliNew.Delete 'Delete the mail

End If
Next 'Move onto next mail in Inbox

End If
End With

Main_Exit:
Set mliNew = Nothing
Set Ns = Nothing
Set oOutlook = Nothing
Exit Sub

AutoImportError :
MsgBox "An error has occurred with the following details:" & vbNewLine &
_
"Descriptio n: " & Err.Description & vbNewLine & _
"Error Number: " & Err.Number & vbNewLine & vbNewLine & _
"Please report these details to the database administrator"
Resume Main_Exit
End Sub
Dec 10 '05 #1
10 1660
>>...will import however many mails exist in their Inbox without
prompting them each time it finds a specific mail. .


if QuestionAuto <> vbyes then QuestionAuto = MsgBox("Intake Manager has
found an email in your Inbox ...

Once they say yes, it won't ask again.

Dec 10 '05 #2
I maybe missing the point here but wont the message box show again as it
exists within the FOR loop? It needs to exist here ( I believe) as I only
want it show if a mail from a specific sender exists within the Inbox!!!

Many thanks,

Mark
"Pachydermi tis" <pr*******@gmai l.com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
...will import however many mails exist in their Inbox without
prompting them each time it finds a specific mail. .


if QuestionAuto <> vbyes then QuestionAuto = MsgBox("Intake Manager has
found an email in your Inbox ...

Once they say yes, it won't ask again.

Dec 10 '05 #3

"Mark" <ma*********@nt lworld.com> wrote in message
news:mR******** *********@newsf e3-gui.ntli.net...
I maybe missing the point here but wont the message box show again as it
exists within the FOR loop? It needs to exist here ( I believe) as I only
want it show if a mail from a specific sender exists within the Inbox!!!

Many thanks,

Mark
With that code, if the user selects Yes, then the msgbox would not show
again. Note, that it tests for QuestionAuto before executing. Once the users
presses Yes, QuestionAuto will remain equal to vbYes.

If this isn't the behavior that you wanted, I think you need to explain more
clearly exactly what you want the message box to do.

I'm guessing that what you want is 3 choices: Import Yes, Import No, Import
All. But that's just a guess.

Randy
"Pachydermi tis" <pr*******@gmai l.com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
...will import however many mails exist in their Inbox without
prompting them each time it finds a specific mail. .


if QuestionAuto <> vbyes then QuestionAuto = MsgBox("Intake Manager has
found an email in your Inbox ...

Once they say yes, it won't ask again.



Dec 10 '05 #4
Your assumption is correct in as much as I would like the 3 choices you
describe. What I am getting is a message on the screen every time a mail is
found from "AS400 George".

Apologies for the vague descriptions,
Mark

"Randy Harris" <ra***@SpamFree .com> wrote in message
news:ta******** ***********@new ssvr29.news.pro digy.net...

"Mark" <ma*********@nt lworld.com> wrote in message
news:mR******** *********@newsf e3-gui.ntli.net...
I maybe missing the point here but wont the message box show again as it
exists within the FOR loop? It needs to exist here ( I believe) as I only
want it show if a mail from a specific sender exists within the Inbox!!!

Many thanks,

Mark


With that code, if the user selects Yes, then the msgbox would not show
again. Note, that it tests for QuestionAuto before executing. Once the
users
presses Yes, QuestionAuto will remain equal to vbYes.

If this isn't the behavior that you wanted, I think you need to explain
more
clearly exactly what you want the message box to do.

I'm guessing that what you want is 3 choices: Import Yes, Import No,
Import
All. But that's just a guess.

Randy
"Pachydermi tis" <pr*******@gmai l.com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
>>>...will import however many mails exist in their Inbox without
>>>prompting them each time it finds a specific mail. .
>
> if QuestionAuto <> vbyes then QuestionAuto = MsgBox("Intake Manager has
> found an email in your Inbox ...
>
> Once they say yes, it won't ask again.
>


Dec 11 '05 #5

"Mark" <ma*********@nt lworld.com> wrote in message
news:ow******** ***********@new sfe4-win.ntli.net...
Your assumption is correct in as much as I would like the 3 choices you
describe. What I am getting is a message on the screen every time a mail is found from "AS400 George".

Apologies for the vague descriptions,
Mark


Mark, if I understand what you need, the message box just isn't going to be
adequate.

I think what you have is this. The user has a number of messages and is
given the option to import each one. If I've got this right, you really
need 4 choices. Something along the lines of:

Yes
No
Yes to All
No to All (or Exit)

For an effective UI you really need the fourth one. Suppose the user is
going through a long list and wishes to stop. He would then need to choose
No for each message or choose Yes to All, which might not be want he wants.

You should create a simple form with the four command buttons. You can
easily make this look like a message box, but with all of the buttons you
need. If you wish, you can make the form modal, like a msgbox, so that the
user must make a selection to continue.

To get the Yes to All effect, you can simply set a public variable, then
have the message scan code skip the prompt when that variable gets set. We
can help you with the code. Don't be intimidated.

Randy

Dec 12 '05 #6
Hi Randy,
I think I understand where you are going with this. Rather than ask for
help from the offset, I'd like to have a go with researching this before I
start as "Public Variables" are a new concept for me. Please keep an eye on
this thread as I'll no doubt need some help with it.

Thanks for your time,

Mark

"Mark" <ma*********@nt lworld.com> wrote in message
news:ow******** ***********@new sfe4-win.ntli.net...
Your assumption is correct in as much as I would like the 3 choices you
describe. What I am getting is a message on the screen every time a mail
is found from "AS400 George".

Apologies for the vague descriptions,
Mark

"Randy Harris" <ra***@SpamFree .com> wrote in message
news:ta******** ***********@new ssvr29.news.pro digy.net...

"Mark" <ma*********@nt lworld.com> wrote in message
news:mR******** *********@newsf e3-gui.ntli.net...
I maybe missing the point here but wont the message box show again as it
exists within the FOR loop? It needs to exist here ( I believe) as I
only
want it show if a mail from a specific sender exists within the Inbox!!!

Many thanks,

Mark


With that code, if the user selects Yes, then the msgbox would not show
again. Note, that it tests for QuestionAuto before executing. Once the
users
presses Yes, QuestionAuto will remain equal to vbYes.

If this isn't the behavior that you wanted, I think you need to explain
more
clearly exactly what you want the message box to do.

I'm guessing that what you want is 3 choices: Import Yes, Import No,
Import
All. But that's just a guess.

Randy
"Pachydermi tis" <pr*******@gmai l.com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
>>>...will import however many mails exist in their Inbox without
>>>prompting them each time it finds a specific mail. .
>
> if QuestionAuto <> vbyes then QuestionAuto = MsgBox("Intake Manager
> has
> found an email in your Inbox ...
>
> Once they say yes, it won't ask again.
>


Dec 12 '05 #7

"Mark" <ma*********@nt lworld.com> wrote in message
news:9E******** ********@newsfe 3-gui.ntli.net...
Hi Randy,
I think I understand where you are going with this. Rather than ask for help from the offset, I'd like to have a go with researching this before I
start as "Public Variables" are a new concept for me. Please keep an eye on this thread as I'll no doubt need some help with it.

Thanks for your time,

Mark


I'll be here as will lots of others.

Good Luck,
Randy

Dec 12 '05 #8
HI Randy,
I managed to acheive what I wanted but not probably as you imagined. As
you suggested, I created a form to mimic a MsgBox with my custom buttons.
Once the CheckInbox sub was called and an email found, the custom MsgBox was
opened. This form contained a hidden text box which had a default value of
null. By clicking on any of the buttons, the text box was populated wih a
one, all or none.
When the sub opened the form, it checked to see if the value was null, if so
exited the sub.

By clicking on any of the buttons, the sub was called again. Now with a
'variable' in the form, I could import one, all or none!!!

Many thanks for pointing me in the right direction :o)

Public Sub CheckInbox(Save Path As String, StatusPart As Integer)
On Error GoTo AutoImportError
Dim mliNew As MailItem
Dim Ns As NameSpace
Dim oOutlook As Outlook.Applica tion
Set oOutlook = New Outlook.Applica tion
Set Ns = oOutlook.GetNam espace("MAPI")
Set mfrInbox = Ns.GetDefaultFo lder(olFolderIn box)
With mfrInbox
Forms!frm_switc hboard!txt_Inbo xCount = .Items.Count
DoEvents

If .Items.Count = 0 Then 'No mails in Inbox
Forms!frm_switc hboard!txt_Inbo xCount = .Items.Count
Exit Sub 'Quit the routine if no mails exist
End If
.Items.Sort "SenderName ", True
'Go through every email in the Inbox

For Each mliNew In .Items

If mliNew.SenderNa me = "AS400 George" Then 'Mail is one we're looking for

'If the MsgBox is open, it needs to be invisible
If SysCmd(acSysCmd GetObjectState, acForm, "frm_ImpAle rt") = 1 Then
DoCmd.OpenForm "frm_ImpAle rt", acNormal, , , , acHidden
Else
DoCmd.OpenForm "frm_ImpAle rt", acNormal, , , , acWindowNormal
End If
DoEvents

If Forms!frm_ImpAl ert!Txt_ImpValu e = "None" Then 'They don't want to
import to exit code
DoCmd.Close acForm, "frm_ImpAle rt"
Exit Sub
ElseIf IsNull(Forms!fr m_ImpAlert!Txt_ ImpValue) Then ' No selection has
been made
Exit Sub
End If
mliNew.Attachme nts.Item(1).Sav eAsFile SavePath 'Save the attachment

ImportRatio 'Colleact ratio items sub

If Not IsNull(DLookup( "psku", "tbl_tmp_ratio" )) Then
DoCmd.Close acForm, "frm_ImpAle rt"
DoEvents
MsgBox "During the Auto Import proceedure, a ratio sku was found in the
text file" & vbCrLf & _
"that doesn't exist in the database!" & vbCrLf & _
"Please update the ratio sku information now!!" & vbCrLf & vbCrLf & _
"The database will attempt the import again within the hour",
vbCritical, "New Ratio Sku"

DoCmd.SetWarnin gs False
DoCmd.RunSQL "delete * from tbl_tmp_ratio;" 'Clear the temp ratio
table
DoCmd.SetWarnin gs True
Exit Sub
End If
ImportNewDay 'Run the Import proceedure
mliNew.Delete 'Delete the mail

If Forms!frm_ImpAl ert!Txt_ImpValu e = "One" Then
DoCmd.Close acForm, "frm_ImpAle rt"
Exit Sub
End If
End If

Next 'Move onto next mail in Inbox

End With

DoCmd.Close acForm, "frm_ImpAle rt"
Main_Exit:
Set mliNew = Nothing
Set Ns = Nothing
Set oOutlook = Nothing
Exit Sub

AutoImportError :
MsgBox "An error has occurred with the following details:" & vbNewLine &
_
"Descriptio n: " & Err.Description & vbNewLine & _
"Error Number: " & Err.Number & vbNewLine & vbNewLine & _
"Please report these details to the database administrator"
Resume Main_Exit
End Sub
"Mark" <ma*********@nt lworld.com> wrote in message
news:9E******** ********@newsfe 3-gui.ntli.net...
Hi Randy,
I think I understand where you are going with this. Rather than ask for
help from the offset, I'd like to have a go with researching this before I
start as "Public Variables" are a new concept for me. Please keep an eye
on
this thread as I'll no doubt need some help with it.

Thanks for your time,

Mark

"Mark" <ma*********@nt lworld.com> wrote in message
news:ow******** ***********@new sfe4-win.ntli.net...
Your assumption is correct in as much as I would like the 3 choices you
describe. What I am getting is a message on the screen every time a mail
is found from "AS400 George".

Apologies for the vague descriptions,
Mark

"Randy Harris" <ra***@SpamFree .com> wrote in message
news:ta******** ***********@new ssvr29.news.pro digy.net...

"Mark" <ma*********@nt lworld.com> wrote in message
news:mR******** *********@newsf e3-gui.ntli.net...
I maybe missing the point here but wont the message box show again as
it
exists within the FOR loop? It needs to exist here ( I believe) as I
only
want it show if a mail from a specific sender exists within the
Inbox!!!

Many thanks,

Mark

With that code, if the user selects Yes, then the msgbox would not show
again. Note, that it tests for QuestionAuto before executing. Once the
users
presses Yes, QuestionAuto will remain equal to vbYes.

If this isn't the behavior that you wanted, I think you need to explain
more
clearly exactly what you want the message box to do.

I'm guessing that what you want is 3 choices: Import Yes, Import No,
Import
All. But that's just a guess.

Randy

"Pachydermi tis" <pr*******@gmai l.com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
>>>...will import however many mails exist in their Inbox without
>>>prompting them each time it finds a specific mail. .
>
> if QuestionAuto <> vbyes then QuestionAuto = MsgBox("Intake Manager
> has
> found an email in your Inbox ...
>
> Once they say yes, it won't ask again.
>



Dec 16 '05 #9
Thanks for posting back the results Mark. I'm glad it worked out.

--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.

Dec 16 '05 #10

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

Similar topics

3
2082
by: Marc Walgren | last post by:
Greetings I have an ASP application to enter reservations. There are multiple user security settings that require some users to have a restricted list of client in a drop list on a form. I constructed the following function: CREATE FUNCTION (@pUserId int)
64
3278
by: Chris Rodriguez | last post by:
after creating a couple of mediocre sites and talking too much about them, i've been overwhelmed w/ requests for new sites & site make-overs. i have a full-time job and i don't have the time or skills to develop what companies are asking of me. i'd like to capitalize on this by hiring someone to do all the production once i've sold the site. i'm not courting anyone who's considering a massive e-commerce site or anything that extensive, but...
16
2235
by: Jonas Smithson | last post by:
I'm going to say something now that may seem to completely contradict a previous post of mine, in which I basically said that taking a "who cares" attitude about certain browsers (because of their non-standard CSS rendering) makes no sense. Well, you have to draw the line *somewhere*... and contradictory or not, I've decided that I've suffered with Netscape 4 for long enough. Coding workarounds for its brain-dead CSS rendering has...
7
1909
by: Fendi Baba | last post by:
The function is called from opencalendar(targetfield). Thanks for any hints on what could be the problem. .............................................................. var decimalPointDelimiter = ".";
5
4321
by: Simone | last post by:
Hello All. I would like some advice. What is the best way to make an Access database design not accessible? Like accessing tables, form design and etc. Is it a good idea to make a MDE file? What other options do I have? On more question should all users have their own front end? Thanks a lot.
10
1397
by: grocery_stocker | last post by:
Given: int main(void) { char *ptr = "test me"; printf("%s\n", &ptr); } Why would the output be
0
895
by: Miguel Dias Moura | last post by:
Hello, I am saving information about each user in Asp.Net 2.0 profile a using complex type, i.e., a class. I am using a SQL 2005 database as the profile provider. I am also saving the published documents of each user using a <Serializable()> class. My objective is to be able to:
2
2479
by: HSD | last post by:
database not allowing multiusers -------------------------------------------------------------------------------- Background An ACCESS database containing two tables and three forms has been installed on the network drive. Using the Tools Menu (Security Sub Menu), five users have been added to the USERS group in the database. The Users group has been assigned OPEN/RUN permission for the database object. The DEFAULT RECORD LOCKING...
3
2229
scubak1w1
by: scubak1w1 | last post by:
Hello, I am wanting a "pretty output" of tabular data generated on the fly and saved in an array (PHP)... That is, I have a link so users can chart (JpGraph) and download (CSV) tabular data, based on their selections on a query web page and using PHP, etc to pull the data out of a PostgreSQL database. I have been requested to make ('on the fly') a 'reporting quality' version of the CSV available for download - sort of like you might get...
0
9528
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,...
1
10173
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
10006
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7547
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6788
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
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
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4116
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
2
3731
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.