|
-
Jun 25th, 2010, 11:17 AM
#1
Thread Starter
Frenzied Member
Outlook Forms - Task form cancel send
I have created a form and using the code below applied some validation. However The message box in the Write function for some reason fires twice and also after the form is cancelled when the user goes back to the form to fix the errors the send button has disappeared from the toolbar.
Code:
Function Item_Write()
Dim str_ValidRequired
Dim str_ValidIncorrect
str_ValidRequired = ""
str_ValidIncorrect = ""
str_ValidRequired = ValidateRequired
str_ValidIncorrect = ValidateIncomplete
If str_ValidRequired <> "" or str_ValidIncorrect <> "" Then
Item_Write = False
If str_ValidRequired <> "" Then
str_ValidRequired = "The form is incomplete, please complete the following fields- " & VBCrLf & str_ValidRequired
End If
If str_ValidIncorrect <> "" Then
str_ValidIncorrect = "The form contains the following errors please review as described and resubmit the form-" & VBCrLf & str_ValidIncorrect
End If
msgbox str_ValidRequired & str_ValidIncorrect, 64, "Request Validation."
End If
End Function
Function Item_Send()
Dim str_ValidRequired
Dim str_ValidIncorrect
Dim str_ErrorMsg
str_ValidRequired = ""
str_ValidIncorrect = ""
str_ErrorMsg = ""
str_ValidRequired = ValidateRequired
str_ValidIncorrect = ValidateIncomplete
If str_ValidRequired <> "" or str_ValidIncorrect <> "" Then
Item_Send = False
End If
End Function
Function ValidateRequired()
Dim str_List
str_List = ""
Dim txt_Requester
Dim txt_JobTitle
Dim txt_Telephone
Dim txt_Email
Dim txt_RequestTitle
Dim cbo_PracticeArea
Dim cbo_Audience
Dim cbo_RequestAbout
Dim txt_BusinessObjectives
Dim txt_Deadline
Dim txt_RequestOverview
txt_Requester = Item.UserProperties("Requester")
txt_JobTitle = Item.UserProperties("JobTitle")
txt_Telephone = Item.UserProperties("Telephone")
txt_Email = Item.UserProperties("Email")
txt_RequestTitle = Item.UserProperties("RequestTitle")
cbo_PracticeArea = Item.UserProperties("PracticeArea")
cbo_Audience = Item.UserProperties("Audience")
cbo_RequestAbout = Item.UserProperties("RequestAbout")
txt_BusinessObjectives = Item.UserProperties("Objectives")
txt_Deadline = Item.UserProperties("Deadline")
txt_RequestOverview = Item.UserProperties("RequestOverview")
If txt_Requester = "" Then
str_List = str_List & "Requester:" & VBCrLf
End If
If txt_Telephone = "" Then
str_List = str_List & "Telephone:" & VBCrLf
End If
If txt_Email = "" Then
str_List = str_List & "Email:" & VBCrLf
End If
If txt_RequestTitle = "" Then
str_List = str_List & "Request Title:" & VBCrLf
End If
If cbo_PracticeArea = "" Then
str_List = str_List & "Practice Area:" & VBCrLf
End If
If cbo_Audience = "" Then
str_List = str_List & "Audience:" & VBCrLf
End If
If cbo_RequestAbout = "" Then
str_List = str_List & "Request About:" & VBCrLf
End If
If txt_BusinessObjectives = "" Then
str_List = str_List & "Business Objectives:" & VBCrLf
End If
If txt_RequestOverview = "" Then
str_List = str_List & "Request Overview:" & VBCrLf
End If
ValidateRequired = str_List
End Function
Function ValidateIncomplete()
Dim str_List
Dim txt_Deadline
str_List = ""
txt_Deadline = Item.UserProperties("Deadline")
If txt_Deadline < Now() Then
str_List = "Request Deadline must be in the future:" & VBCrLf
End If
ValidateIncomplete = str_List
End Function
-
Jun 25th, 2010, 12:08 PM
#2
Re: Outlook Forms - Task form cancel send
@FG: A function is a procedure that returns a value. You may change the above from
to
Code:
Function Item_Write() as Boolean
Similarly you can change the rest of the 'Functions' as well... to String or Boolean whichever applicable...
The only reason I can think of for that message box coming twice is that your Function is being called twice....
I can see plenty of other errors in the code... One of them for example, Item_Write will always be False...
What exactly are you trying to achieve. Can you show the complete code?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Jun 28th, 2010, 03:08 AM
#3
Thread Starter
Frenzied Member
Re: Outlook Forms - Task form cancel send
Hi Sid,
That is the full code, basically the Item_Write event is the event available in the script editor which fires automatically, I did think it strange that it is a function not a procedure. It Item write and Item send both fire when the send button is pressed and I call my two validate functions to check the values of the text boxes on the form and if required show a message.
If the validation is fine I am happy for it to send and close the form, if the validate functions return a string then I want it to not send and allow the user to revisit the form to re-submit after correcting the errors.
-
Jun 28th, 2010, 03:39 AM
#4
Thread Starter
Frenzied Member
Re: Outlook Forms - Task form cancel send
 Originally Posted by FishGuy
Hi Sid,
That is the full code, basically the Item_Write event is the event available in the script editor which fires automatically, I did think it strange that it is a function not a procedure. It Item write and Item send both fire when the send button is pressed and I call my two validate functions to check the values of the text boxes on the form and if required show a message.
If the validation is fine I am happy for it to send and close the form, if the validate functions return a string then I want it to not send and allow the user to revisit the form to re-submit after correcting the errors.
I googled my problem and found this similar
First time posting to this forum so if this is and old problem please forgive me in advance. Googled the problem and found nothing.
I created a custom form using a task request template and when I tried to handle the send event nothing happened. (VBScript) So I handled open and write and close and they all worked. In fact the Write Event fired twice successively
You can replicate with the following VBScrip
Function Item_Open(
MsgBox "Open
End Functio
Function Item_Read(
MsgBox "Read
End Functio
Function Item_Write(
MsgBox "Write
End Functio
Function Item_Close(
MsgBox "Close
End Functio
Function Item_Send(
MsgBox "Send
End Functio
even in a blank task request form this code doen't fire the Send Event but fires Write twice. It makes it a little hard to do field validation before a send and of course you can't cancel the send. Anybody had similar probs
It looks like I may not find a solution to my problem.
-
Jun 28th, 2010, 04:25 AM
#5
Thread Starter
Frenzied Member
Re: Outlook Forms - Task form cancel send
Ok figured if i add my own send button and add the validation there I may get round this issue, i.e. validate then if tru call the send event myself rather than calling the send/write event then trying to cancel it. Although I don't think this may be possible for the same reason and also I cannot hide the built in Send button on a task form.
I think I may be better sending an email form and creating a task programatically?
Last edited by FishGuy; Jun 28th, 2010 at 04:35 AM.
-
Jun 29th, 2010, 12:29 AM
#6
Re: Outlook Forms - Task form cancel send
The link http://www.outlookcode.com/d/taskform.htm doesn't work...
In fact it takes me to http://www.outlookcode.com/article.aspx?id=60
Can you upload you app? Let me try and see if I can do something about it, if I can...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|