Code to clear certain fields in Outlook Form

Status
Not open for further replies.
D

Delnang

I have a text box for employee number. This field is used to address the CC

field. If the employee number is typed incorrectly and therefore cannot be

resolved and error message show. What I'd like to do is after the message is

acknowledged by the user the employee number field, To, and CC fields are

cleared. Is there code I can add to the jscript to clear those fields?

Angie
 
S

Sue Mosher [MVP]

What jscript are you talking about? What error message?

Sue Mosher

"Delnang" <Delnang> wrote in message

news:CFA0F717-65C2-4456-894D-74B2144ADBCF@microsoft.com...
> I have a text box for employee number. This field is used to address the
> CC
> field. If the employee number is typed incorrectly and therefore cannot
> be
> resolved and error message show. What I'd like to do is after the message
> is
> acknowledged by the user the employee number field, To, and CC fields are
> cleared. Is there code I can add to the jscript to clear those fields?

> Angie
 
D

Delnang

The code reads as follows:

Function Item_Send()

Const olCc = 2

Set objRecip = Item.Recipients.Add

(Item.UserProperties("ManagerEmployeeNumber2"))

If objRecip.Resolve Then

objRecip.Type = olcc

Else

MsgBox "Manager Employee Number is either not valid or blank. Please enter

a valid employee number."

Item_Send = False

End If

End Function

The error message would be what's in the MsgBox line of code.

Thanks,

Angie

"Sue Mosher [MVP]" wrote:


> What jscript are you talking about? What error message?
> > Sue Mosher
> > >

> "Delnang" <Delnang> wrote in message
> news:CFA0F717-65C2-4456-894D-74B2144ADBCF@microsoft.com...
> >I have a text box for employee number. This field is used to address the
> >CC
> > field. If the employee number is typed incorrectly and therefore cannot
> > be
> > resolved and error message show. What I'd like to do is after the message
> > is
> > acknowledged by the user the employee number field, To, and CC fields are
> > cleared. Is there code I can add to the jscript to clear those fields?
> > Angie


> .
>
 
S

Sue Mosher [MVP]

If the recipient doesn't resolve, you should be able to call

objRecip.Delete. If you want to clear all recipients (which would seem to

make more work for the user), set the value of the To and CC properties to

"".

And that's VBScript code that an Outlook form uses, not JScript.

Sue Mosher

"Delnang" <Delnang> wrote in message

news:8C3C7313-6942-4EC5-A56F-25B4B9B41B45@microsoft.com...
> The code reads as follows:
> Function Item_Send()
> Const olCc = 2
> Set objRecip = Item.Recipients.Add
> (Item.UserProperties("ManagerEmployeeNumber2"))
> If objRecip.Resolve Then
> objRecip.Type = olcc
> Else
> MsgBox "Manager Employee Number is either not valid or blank. Please
> enter
> a valid employee number."
> Item_Send = False
> End If
> End Function

> The error message would be what's in the MsgBox line of code.

> Thanks,
> Angie

> "Sue Mosher [MVP]" wrote:
>
> > What jscript are you talking about? What error message?
>

>> "Delnang" <Delnang> wrote in message
> > news:CFA0F717-65C2-4456-894D-74B2144ADBCF@microsoft.com...
> > >I have a text box for employee number. This field is used to address
> > >the
> > >CC
> > > field. If the employee number is typed incorrectly and therefore
> > > cannot
> > > be
> > > resolved and error message show. What I'd like to do is after the
> > > message
> > > is
> > > acknowledged by the user the employee number field, To, and CC fields
> > > are
> > > cleared. Is there code I can add to the jscript to clear those fields?
 
D

Delnang

Sue - Thank you!!! I'll remember that...VBScript not JScript. I think I

have one last question. The VBScript I have now is as follows:

Function Item_Send()

Const olCc = 2

Set objRecip = Item.Recipients.Add

(Item.UserProperties("ManagerEmployeeNumber2"))

If objRecip.Resolve Then

objRecip.Type = olcc

Else

MsgBox "Manager Employee Number is not valid, blank or contains the ""e"".

Please enter a valid employee number."

Item_Send = False

objRecip.Delete

Item.UserProperties("EmployeeNumber")= ""

End If

End Function

What is happening now, is that I can enter a valid Employee Number, but all

other fields (except the Memo field) is locked (won't let me backspace or

highlight/edit). If I were to click in the Memo field then one of the other

fields, I can edit their content. Is there a way the fields can be editible

without having to click the Memo field first?

Angie

"Sue Mosher [MVP]" wrote:


> If the recipient doesn't resolve, you should be able to call
> objRecip.Delete. If you want to clear all recipients (which would seem to
> make more work for the user), set the value of the To and CC properties to
> "".

> And that's VBScript code that an Outlook form uses, not JScript.
> > Sue Mosher
> > >

> "Delnang" <Delnang> wrote in message
> news:8C3C7313-6942-4EC5-A56F-25B4B9B41B45@microsoft.com...
> > The code reads as follows:
> > Function Item_Send()
> > Const olCc = 2
> > Set objRecip = Item.Recipients.Add
> > (Item.UserProperties("ManagerEmployeeNumber2"))
> > If objRecip.Resolve Then
> > objRecip.Type = olcc
> > Else
> > MsgBox "Manager Employee Number is either not valid or blank. Please
> > enter
> > a valid employee number."
> > Item_Send = False
> > End If
> > End Function
> > The error message would be what's in the MsgBox line of code.
> > Thanks,
> > Angie
> > "Sue Mosher [MVP]" wrote:
> >
> >> What jscript are you talking about? What error message?
> >
> >> "Delnang" <Delnang> wrote in message
> >> news:CFA0F717-65C2-4456-894D-74B2144ADBCF@microsoft.com...
> >> >I have a text box for employee number. This field is used to address
> >> >the
> >> >CC
> >> > field. If the employee number is typed incorrectly and therefore
> >> > cannot
> >> > be
> >> > resolved and error message show. What I'd like to do is after the
> >> > message
> >> > is
> >> > acknowledged by the user the employee number field, To, and CC fields
> >> > are
> >> > cleared. Is there code I can add to the jscript to clear those fields?


> .
>
 
S

Sue Mosher [MVP]

Exactly when are you seeing this problem?

Sue Mosher

"Delnang" <Delnang> wrote in message

news:C47376BB-4E8E-4801-802E-0FC79EE3359A@microsoft.com...
> Sue - Thank you!!! I'll remember that...VBScript not JScript. I think I
> have one last question. The VBScript I have now is as follows:

> Function Item_Send()
> Const olCc = 2
> Set objRecip = Item.Recipients.Add
> (Item.UserProperties("ManagerEmployeeNumber2"))
> If objRecip.Resolve Then
> objRecip.Type = olcc
> Else
> MsgBox "Manager Employee Number is not valid, blank or contains the ""e"".
> Please enter a valid employee number."
> Item_Send = False
> objRecip.Delete
> Item.UserProperties("EmployeeNumber")= ""
> End If
> End Function

> What is happening now, is that I can enter a valid Employee Number, but
> all
> other fields (except the Memo field) is locked (won't let me backspace or
> highlight/edit). If I were to click in the Memo field then one of the
> other
> fields, I can edit their content. Is there a way the fields can be
> editible
> without having to click the Memo field first?
> Angie
> "Sue Mosher [MVP]" wrote:
>
> > If the recipient doesn't resolve, you should be able to call
> > objRecip.Delete. If you want to clear all recipients (which would seem to
> > make more work for the user), set the value of the To and CC properties
> > to
> > "".
>

>> "Delnang" <Delnang> wrote in message
> > news:8C3C7313-6942-4EC5-A56F-25B4B9B41B45@microsoft.com...
> > > The code reads as follows:
> > > Function Item_Send()
> > > Const olCc = 2
> > > Set objRecip = Item.Recipients.Add
> > > (Item.UserProperties("ManagerEmployeeNumber2"))
> > > If objRecip.Resolve Then
> > > objRecip.Type = olcc
> > > Else
> > > MsgBox "Manager Employee Number is either not valid or blank. Please
> > > enter
> > > a valid employee number."
> > > Item_Send = False
> > > End If
> > > End Function
> >> > The error message would be what's in the MsgBox line of code.
> >> > Thanks,
> > > Angie
> >> > "Sue Mosher [MVP]" wrote:
> >> >> What jscript are you talking about? What error message?
> > >
>> >> "Delnang" <Delnang> wrote in message
> > >> news:CFA0F717-65C2-4456-894D-74B2144ADBCF@microsoft.com...
> > >> >I have a text box for employee number. This field is used to address
> > >> >the
> > >> >CC
> > >> > field. If the employee number is typed incorrectly and therefore
> > >> > cannot
> > >> > be
> > >> > resolved and error message show. What I'd like to do is after the
> > >> > message
> > >> > is
> > >> > acknowledged by the user the employee number field, To, and CC
> > >> > fields
> > >> > are
> > >> > cleared. Is there code I can add to the jscript to clear those
> > >> > fields?

>

>
>> .
> >
 
D

Delnang

From a user's perspective, it is right after he/she clicks the message box

which would read, "Manager Employee Number is not valid..." Once the OK

button on the "error" is clicked, their cursor goes to the employee number

field. User is allowed to type a new value in Employee Number. However, all

other fields are "locked" meaning one could put their cursor in a field /

backspace or highlight and click delete but nothing happens. However, if

(the user) clicks within the Memo field then out to one of the other fields

(i.e. name, d.o.b) the field is "unlocked" editable and one can put their

cursor in a field and backspace or highlight and click delete.

"Sue Mosher [MVP]" wrote:


> Exactly when are you seeing this problem?
> > Sue Mosher
> > >

> "Delnang" <Delnang> wrote in message
> news:C47376BB-4E8E-4801-802E-0FC79EE3359A@microsoft.com...
> > Sue - Thank you!!! I'll remember that...VBScript not JScript. I think I
> > have one last question. The VBScript I have now is as follows:
> > Function Item_Send()
> > Const olCc = 2
> > Set objRecip = Item.Recipients.Add
> > (Item.UserProperties("ManagerEmployeeNumber2"))
> > If objRecip.Resolve Then
> > objRecip.Type = olcc
> > Else
> > MsgBox "Manager Employee Number is not valid, blank or contains the ""e"".
> > Please enter a valid employee number."
> > Item_Send = False
> > objRecip.Delete
> > Item.UserProperties("EmployeeNumber")= ""
> > End If
> > End Function
> > What is happening now, is that I can enter a valid Employee Number, but
> > all
> > other fields (except the Memo field) is locked (won't let me backspace or
> > highlight/edit). If I were to click in the Memo field then one of the
> > other
> > fields, I can edit their content. Is there a way the fields can be
> > editible
> > without having to click the Memo field first?
> > Angie
> > "Sue Mosher [MVP]" wrote:
> >
> >> If the recipient doesn't resolve, you should be able to call
> >> objRecip.Delete. If you want to clear all recipients (which would seem to
> >> make more work for the user), set the value of the To and CC properties
> >> to
> >> "".
> >
> >> "Delnang" <Delnang> wrote in message
> >> news:8C3C7313-6942-4EC5-A56F-25B4B9B41B45@microsoft.com...
> >> > The code reads as follows:
> >> > Function Item_Send()
> >> > Const olCc = 2
> >> > Set objRecip = Item.Recipients.Add
> >> > (Item.UserProperties("ManagerEmployeeNumber2"))
> >> > If objRecip.Resolve Then
> >> > objRecip.Type = olcc
> >> > Else
> >> > MsgBox "Manager Employee Number is either not valid or blank. Please
> >> > enter
> >> > a valid employee number."
> >> > Item_Send = False
> >> > End If
> >> > End Function
> >> >> > The error message would be what's in the MsgBox line of code.
> >> >> > Thanks,
> >> > Angie
> >> >> > "Sue Mosher [MVP]" wrote:
> >> >> >> What jscript are you talking about? What error message?
> >> >
> >> >> "Delnang" <Delnang> wrote in message
> >> >> news:CFA0F717-65C2-4456-894D-74B2144ADBCF@microsoft.com...
> >> >> >I have a text box for employee number. This field is used to address
> >> >> >the
> >> >> >CC
> >> >> > field. If the employee number is typed incorrectly and therefore
> >> >> > cannot
> >> >> > be
> >> >> > resolved and error message show. What I'd like to do is after the
> >> >> > message
> >> >> > is
> >> >> > acknowledged by the user the employee number field, To, and CC
> >> >> > fields
> >> >> > are
> >> >> > cleared. Is there code I can add to the jscript to clear those
> >> >> > fields?
> >
> >
> >> .
> >>


> .
>
 
S

Sue Mosher [MVP]

I have no idea why other controls would be responsive, unless you have some

code on the item that sets those controls to read-only.

Sue Mosher

"Delnang" <Delnang> wrote in message

news:82BC8B71-0164-45B3-9E66-724CF7F9986B@microsoft.com...
> From a user's perspective, it is right after he/she clicks the message box
> which would read, "Manager Employee Number is not valid..." Once the OK
> button on the "error" is clicked, their cursor goes to the employee number
> field. User is allowed to type a new value in Employee Number. However,
> all
> other fields are "locked" meaning one could put their cursor in a field /
> backspace or highlight and click delete but nothing happens. However, if
> (the user) clicks within the Memo field then out to one of the other
> fields
> (i.e. name, d.o.b) the field is "unlocked" editable and one can put their
> cursor in a field and backspace or highlight and click delete.
>
> > > Sue - Thank you!!! I'll remember that...VBScript not JScript. I think
> > > I
> > > have one last question. The VBScript I have now is as follows:
> >> > Function Item_Send()
> > > Const olCc = 2
> > > Set objRecip = Item.Recipients.Add
> > > (Item.UserProperties("ManagerEmployeeNumber2"))
> > > If objRecip.Resolve Then
> > > objRecip.Type = olcc
> > > Else
> > > MsgBox "Manager Employee Number is not valid, blank or contains the
> > > ""e"".
> > > Please enter a valid employee number."
> > > Item_Send = False
> > > objRecip.Delete
> > > Item.UserProperties("EmployeeNumber")= ""
> > > End If
> > > End Function
> >> > What is happening now, is that I can enter a valid Employee Number, but
> > > all
> > > other fields (except the Memo field) is locked (won't let me backspace
> > > or
> > > highlight/edit). If I were to click in the Memo field then one of the
> > > other
> > > fields, I can edit their content. Is there a way the fields can be
> > > editible
> > > without having to click the Memo field first?
> > > Angie
> > > "Sue Mosher [MVP]" wrote:
> >> >> If the recipient doesn't resolve, you should be able to call
> > >> objRecip.Delete. If you want to clear all recipients (which would seem
> > >> to
> > >> make more work for the user), set the value of the To and CC
> > >> properties
> > >> to
> > >> "".
> > >
>> >> "Delnang" <Delnang> wrote in message
> > >> news:8C3C7313-6942-4EC5-A56F-25B4B9B41B45@microsoft.com...
> > >> > The code reads as follows:
> > >> > Function Item_Send()
> > >> > Const olCc = 2
> > >> > Set objRecip = Item.Recipients.Add
> > >> > (Item.UserProperties("ManagerEmployeeNumber2"))
> > >> > If objRecip.Resolve Then
> > >> > objRecip.Type = olcc
> > >> > Else
> > >> > MsgBox "Manager Employee Number is either not valid or blank.
> > >> > Please
> > >> > enter
> > >> > a valid employee number."
> > >> > Item_Send = False
> > >> > End If
> > >> > End Function
> > >>> >> > The error message would be what's in the MsgBox line of code.
> > >>> >> > Thanks,
> > >> > Angie
> > >>> >> > "Sue Mosher [MVP]" wrote:
> > >>> >> >> What jscript are you talking about? What error message?
> > >> >
>> >> >> "Delnang" <Delnang> wrote in message
> > >> >> news:CFA0F717-65C2-4456-894D-74B2144ADBCF@microsoft.com...
> > >> >> >I have a text box for employee number. This field is used to
> > >> >> >address
> > >> >> >the
> > >> >> >CC
> > >> >> > field. If the employee number is typed incorrectly and therefore
> > >> >> > cannot
> > >> >> > be
> > >> >> > resolved and error message show. What I'd like to do is after
> > >> >> > the
> > >> >> > message
> > >> >> > is
> > >> >> > acknowledged by the user the employee number field, To, and CC
> > >> >> > fields
> > >> >> > are
> > >> >> > cleared. Is there code I can add to the jscript to clear those
> > >> >> > fields?
> > >
>> >
>> >> .
> > >>

>

>
>> .
> >
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
P Color Code or highlight folders in Outlook 2016 Using Outlook 2
N Please advise code received new mail Using Outlook 0
B Outlook 2016 Unable to view images or logos on the outlook 2016 emails the same html code works well when i use outlook 2010 Using Outlook 0
S Excel vba code to manage outlook web app Using Outlook 10
S Outlook VBA How to adapt this code for using in a different Mail Inbox Outlook VBA and Custom Forms 0
S Add VBA save code Using Outlook 0
C Auto Run VBA Code on new email Outlook VBA and Custom Forms 1
witzker Pls help to change the code for inserting date in Ol contact body Outlook VBA and Custom Forms 5
I Outlook 2003 shows html code when To: field is empty Using Outlook 7
F VBA code to dock Styles whenever I write or edit an email Outlook VBA and Custom Forms 0
S Skype for business meeting vba code Outlook VBA and Custom Forms 1
R Expand VBA Permanent Delete Code Outlook VBA and Custom Forms 6
B Outlook Business Contact Manager with SQL to Excel, User Defined Fields in BCM don't sync in SQL. Can I use VBA code to copy 1 field to another? BCM (Business Contact Manager) 0
A VBA Code in Outlook disappears after first use Outlook VBA and Custom Forms 1
Alex Cotton "invalid or unqualified reference" on code that should work Outlook VBA and Custom Forms 5
F VBA to ensure a code is entered in Subject title Outlook VBA and Custom Forms 1
Z Outlook Custom Form: Adding Dropdown(Project Code) at the end of subject Outlook VBA and Custom Forms 0
D Any updates or fixes that would make this code stop working just moving emails to another folder Outlook VBA and Custom Forms 1
N Open & Save VBAProject.Otm using VBA Code Outlook VBA and Custom Forms 1
M error code 0x8DE00006 Using Outlook 1
R VBA Code to permanently delete selected email Outlook VBA and Custom Forms 10
dyny723 Outlook 2016: Code to link a contact to emails received from that contact Outlook VBA and Custom Forms 1
D Command Button code will not execute. Any suggestions Please. Outlook VBA and Custom Forms 2
V VB script code to save a specific email attachment from a given email Outlook VBA and Custom Forms 14
J Custom form code doesn't run Outlook VBA and Custom Forms 2
M code to move selected Outlook contacts to another folder Using Outlook 3
E Outlook Form - Voting Responses Not Auto Processing If Form Contains Any Code Outlook VBA and Custom Forms 0
C Need VBA code to automatically save message outside outlook and add date Outlook VBA and Custom Forms 1
S Problem running Command button code Outlook VBA and Custom Forms 2
D Help with code to move mail on receipt to another folder based on time received Outlook VBA and Custom Forms 2
C Color Code New Calendar Items Using Outlook 2
S VBA Code to move mail items from search folder to inbox subfolder Outlook VBA and Custom Forms 4
B Automation error running VB macro code Outlook VBA and Custom Forms 8
S my vbscript button1_click code works on appointment created but not on opening an existing apntmn Outlook VBA and Custom Forms 16
M regarding the Create Contacts From Messages code Using Outlook 8
J Outlook 2010 VBScript editor does not run code at all Outlook VBA and Custom Forms 0
B VBA Code to create appointment from email Outlook VBA and Custom Forms 1
D VBA Code to strip Subject Line when replying or forwarding Using Outlook 3
L Outlook 2007 Contact Form Code Not Working Using Outlook 20
S The attempted operation failed ... 2nd time running code Outlook VBA and Custom Forms 3
A Check for attachment code not working Outlook VBA and Custom Forms 1
A Code to automatically delete message after sending Outlook VBA and Custom Forms 6
T What code to use to move the custom field values to message body when sending e-mail ? Outlook VBA and Custom Forms 8
G Annoying page of code when receiving Using Outlook 14
M VBA Code to Restart Outlook on error Outlook VBA and Custom Forms 3
Z Default VBA code for extracting data from email (Outlook) to Excel? Outlook VBA and Custom Forms 1
T VBA to Sort Rules [A-Z] - code provided Outlook VBA and Custom Forms 9
M VBA Auto-Reply code for Two Mailboxes on one Outlook Session. Outlook VBA and Custom Forms 4
Z Protecting VBA code - anything new? Outlook VBA and Custom Forms 2
S Outlook 2010 I am getting error code 0x8DE00006 'the operation failed'. outlook 2010 send/receive progress Using Outlook.com accounts in Outlook 2

Similar threads

Top