A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Items.find criteria



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 19th 09, 01:12 AM posted to microsoft.public.outlook.program_vba
Gitche Gumee
external usenet poster
 
Posts: 6
Default Items.find criteria

I am using the following code to select a contact for updating.

Set myItem = myContacts.Items.Find("[FirstName] = " & strFirstName & " and
[LastName] = " & strLastName & "")

This works, but I also need to check that another field [Customer ID] is
null before making the update. Is that possible?
Ads
  #2  
Old April 19th 09, 07:42 PM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Items.find criteria



When Find has returned an item, check its property.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Sat, 18 Apr 2009 17:12:01 -0700 schrieb Gitche Gumee:

I am using the following code to select a contact for updating.

Set myItem = myContacts.Items.Find("[FirstName] = " & strFirstName & " and
[LastName] = " & strLastName & "")

This works, but I also need to check that another field [Customer ID] is
null before making the update. Is that possible?

  #3  
Old April 20th 09, 12:54 AM posted to microsoft.public.outlook.program_vba
Gitche Gumee
external usenet poster
 
Posts: 6
Default Items.find criteria

This is helpful, but I'm still having trouble. I'm new to Outlook VBA; maybe
I don't know the right syntax.

Here's my code:

Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts)
Set myItem = myContacts.Items.Find("[FirstName] = " & strFirstName
& " and [LastName] = " & strLastName & "")

While TypeName(myItem) "Nothing"
If IsNull(myItem.CustomerID) Then
myItem.CustomerID = strCustomerID
myItem.User2 = strEntryID
myItem.Save
End If
Set myItem = myContacts.FindNext
Wend

The error number is 438, "Object doesn't support this property or method."

I have also tried If myitem.CustomerID = "", with same error.



"Michael Bauer [MVP - Outlook]" wrote:



When Find has returned an item, check its property.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Sat, 18 Apr 2009 17:12:01 -0700 schrieb Gitche Gumee:

I am using the following code to select a contact for updating.

Set myItem = myContacts.Items.Find("[FirstName] = " & strFirstName & " and
[LastName] = " & strLastName & "")

This works, but I also need to check that another field [Customer ID] is
null before making the update. Is that possible?


  #4  
Old April 20th 09, 02:30 AM posted to microsoft.public.outlook.program_vba
Gitche Gumee
external usenet poster
 
Posts: 6
Default Items.find criteria

Got it. Here is the fixed code:

Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts).Ite ms

Set myItem = myContacts.Find("[FirstName] = """ & strFirstName &
""" and [LastName] = """ & strLastName & """"

While TypeName(myItem) "Nothing"
If myItem.CustomerID = "" Then
myItem.CustomerID = strCustomerID
myItem.User2 = strEntryID
myItem.Save
End If

Set myItem = myContacts.FindNext

Wend






"Michael Bauer [MVP - Outlook]" wrote:



When Find has returned an item, check its property.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Sat, 18 Apr 2009 17:12:01 -0700 schrieb Gitche Gumee:

I am using the following code to select a contact for updating.

Set myItem = myContacts.Items.Find("[FirstName] = " & strFirstName & " and
[LastName] = " & strLastName & "")

This works, but I also need to check that another field [Customer ID] is
null before making the update. Is that possible?


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you find missing calendar items JHodges Outlook - Calandaring 1 September 14th 08 02:48 AM
How do I save advanced find criteria for future searches British Baldeagle Outlook - Calandaring 0 June 25th 08 04:31 PM
Is it possible to set a default folder for find/save search criteria? Ian R Outlook Express 1 March 9th 07 12:00 PM
Items Find Julieta Prandi Add-ins for Outlook 3 April 7th 06 08:12 PM
2003 calendar's find, doesn't find items created today till tomarr Support7556 Outlook - Calandaring 11 January 20th 06 09:54 PM


All times are GMT +1. The time now is 01:38 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.