Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assistance with where clause coding

Status
Not open for further replies.

theConjurian

IS-IT--Management
May 4, 2002
35
CA
I have a module that will manipulate "appointments" in an Outlook calendar. The calendar entry has a reference number that is keyed to the Access database.

Unfortunately, I cannot use a custom field to hold this reference number as there are other restrictions which prevent this.

I have this reference number in the Message field along with specific details of the appointment.

The message field begins:
Reference: \n Booking No: 1063.1 \n Status: Confirmed ...

To create the record set of objCalendarItems I need an strWhere statement that reads as in the following PSEUDO code:
ii = len (ReferenceNo & "." & LineNo)
strWhere = "Left([Message], 29 + ii) = """ & "Reference: " & "\n" & " Booking No: " & ReferenceNo & "." & No & """"

objAllCalendarItems.Sort "[Message]", True
Set objCalendarItems = objAllCalendarItems.Restrict(strWhere)

This form of code does not work.

Can someone suggest another approach or the correct coding??
 
My knowledge of the outlook automation is zero but I would add a line to debug strWhere:

Code:
ii = len (ReferenceNo & "." & LineNo)
strWhere = "Left([Message], 29 + ii) = """ & "Reference: " & "\n" & " Booking No: " & ReferenceNo & "." & No & """"
debug.Print strWhere    [COLOR=#A40000]'take a look at the variable for troubleshooting[/color]
objAllCalendarItems.Sort "[Message]", True
Set objCalendarItems = objAllCalendarItems.Restrict(strWhere)

You can then open the immediate window to see if the value is as expected.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
strWhere displays as
Left([Message], 29 + ii) = "Reference:\n Booking No: 1031.1"

Throws the following error:
Runtime error '440':
Condition is not valid.
 
>strWhere displays as
>Left([Message], 29 + ii) = "Reference:\n Booking No: 1031.1"

But my goal for [tt]strWhere[/tt] is to display:[red]
???[/red]

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top