Link to home
Start Free TrialLog in
Avatar of mrwilde
mrwildeFlag for Australia

asked on

Create search button for specific entry

What I require is a Macro witch preduces a field entry to be searched in calendar

information:
i enter data into calendar days in relation 2 items manufactured and packed ina standard format e.g

Build; 108L 21157 --B387990 or Mfg; 250Kg 21157 --B387897

the search is for the B387990 Bin number. So clicking the macro button will bring up window to enter in bin.

I have created some macro's in the past with VBscript but I am not very confidetn with the code so any help is greatly appreciated
Avatar of David Lee
David Lee
Flag of United States of America image

mrwilde,

What field are you storing the bin number in?
Avatar of mrwilde

ASKER

I have been entering it into the subject field
ASKER CERTIFIED SOLUTION
Avatar of David Lee
David Lee
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mrwilde

ASKER

Thanks so much, it looks like you put some work into it

I have entered the code you given me into the editor. When running the macro I get the dialog box but no results window. Some points of interest

there are several other macros in the module listing where I placed the B block of code. Does this code need presedence?

Every entry is in the subject line of the calendar like this
Mfg; 250Kg 21157 --B387897
Can we set up the search to always allow for the wildcard?


what should i look for in the macro that is stopping?

You're welcome.  No, the order the macros are in doesn't make any difference.  The procedure names (i.e. Sub X, or Function Y) just need to be unique.  They must be or you'd have gotten an "ambiguous name" error.  Yes, we can change the macro to automatically include the wildcard.  Change this line

    strValue = InputBox("What value shall I search for?" & vbCrLf & "(Use % for a wildcard)", "Bin Search")

to

    strValue = InputBox("What value shall I search for?", "Bin Search")

And this line

    strCondition = "urn:schemas:mailheader:subject LIKE '" & strValue & "'"

to

    strCondition = "urn:schemas:mailheader:subject LIKE '%" & strValue & "'"


Are the items you're searching for in your default calendar?
Avatar of mrwilde

ASKER

No they are not
Then that's why we aren't finding them.  Where are they?
Avatar of mrwilde

ASKER

Calendar in public folder
Avatar of mrwilde

ASKER

IT Managment in Public Folders
Change this line

    strFolder = "Calendar"

to

    strFolder = "'\\Public Folders\All Public Folders\IT Management'"
Avatar of mrwilde

ASKER

I have recieved an error
---------------------------
Microsoft Visual Basic
---------------------------
Compile error:

End If without block If
---------------------------
OK   Help  
---------------------------
what do ya reckon?
Avatar of mrwilde

ASKER

it's ok I found the line I accidently deleted

but it returned an error after entering the search criteria

runtime error '-2147024809 (80070057)':

Could not preform the operation. One or more parameter values are not valid

then when I select debug it highlights this line
Set olkSearch = Application.AdvancedSearch(strFolder, strCondition)
There's only one IF and one corresponding END IF in the code.  Are they still there?  If so, then look to see that there are a matching number of quotes (both single and double) and parenthesis on the lines between the IF and END IF.  Pay particular attention to the lines we just changed.
Look at the strFolder line we just changed.  Is the public folder path correct?  Is that path surrounded by "' and '" (double quote single quote and single quote double quote)?
Avatar of mrwilde

ASKER

Closer inspection revealed I cant spell
IT Managment is the folder name

So changed that and recieved this error

The operation Failed

entering the Debug highlighted this
Set olkSearchFolder = olkSearch.Save("Bin Number")
Take a look at Search Folders and see if a folder with that name already exists.
Avatar of mrwilde

ASKER

Sorry for the delay in my reply, system errors

I still have the error
and the highlight

Set olkSearchFolder = olkSearch.Save("Bin Number")

No there is no other folder in the search folders
As a test, try changing the folder name (i.e. change "Bin Number" to something else) and see what happens.  I've run the script here repeatedly and the only time I get and error on that line is when a fodler with the same name already exists.  If the save works with the different folder name, then there must be a folder called "Bin Number" there somewhere.  If it fails, then something else is wrong.
I believe I deserve credit for answering this question.