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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CMD Button to add contacts from Outlook

Status
Not open for further replies.

vanlanjl

Programmer
Jan 14, 2009
93
US
I noticed in one of the templates from Access that it has the option to click a cmdButton and it opens the search window in Outlook to add contacts to the form and table in outlook. I have tried to replicate this but to no avail. Any Ideas?
Thanks
 
Lets start with the combo box. The code I posted only searches by the Last Name field and the row source for my combo box only has the Last Name field in it.
"Select tblContacts.[Last Name] From tblContacts;"

If your select statement contains more than just the Last Name field, then the code I posted won't work without some modification.

Start small, and just add the Last Name field to your Row Source statement. See if you can find the records you need that way. Then if you need to expand you search abilities, we can work on that.

Now the form. What is the embedded macro on the Form On Load event?

Have you checked the Filter property for the Form to make sure it's not filtering by something that isn't returning records? The properties are set to something that makes me think that might be the problem.
I don't quite know what the
Filter 1=0 property implies, but try getting rid of that expression and see if you get records showing in the form.

Post back with your results

Paul
 
I just set my Filter property to 1 = 0 and it didn't show any records so that definately restricts what you'll see in the form.

Paul
 
Yea the filter has been rest and it populates the fields on the form. So the combo box works great now.
But the outlook button still isn't quite right.

It will open the outlook search user window and will update the the tblcontacts but will not populate the form
 
If you take the filter off the form, what records are populating the form? They have to come from somewhere and I assumed without the filter those records would come from tblContact. So it seems logical that if you import to the table from Outlook that it would show in the form. I suppose you might need to refresh the form, but that's not the way it works in my copy.
What is the embedded macro in the Form On Load event?

Paul
 
WHen i open the form frmContacts it opens with the contact info from the first record.
The embedded Macro follows:

Code:
Condition                
1 -- is null([openargs])      
2                         
3 -- Not[currentproject].[ISTrusted]    
4
5
6
7 -- [TempVars]![Space]=0 And [TempVars]![NewData]<>""
8 -- [TempVars]![Space]>0
9 --
10
11

Code:
Action
1 -- StopMacro
2 -- GoToRecord
3 -- StopMacro
4 -- SetTempVar
5 -- SEtTempVar
6 -- OnError
7 -- SetValue
8 -- SetValue
9 -- SetValue
10 - RemoveTempVar
11 - RemoveTempVar

Code:
Arguments
1 -- 
2 -- , , New, 
3 -- 
4 --NewData, Mid(Nz([OpenArgs]),InStr(Nz([OpenArgs]),"=")+1)
5 -- Space, InStrRev([TempVars]![NewData]," ")
6 -- Next, 
7 -- [Last Name], [TempVars]![NewData]
8 -- [First Name], Left([TempVars]![NewData],[TempVars]![Space]-1)
9 -- [Last Name], Mid([TempVars]![NewData],[TempVars]![Space]+1)
10 - NewData
11 - Space

Hope that helps. And thanks again for all your help!
 
Sorry, somehow I missed the post dated 16 Jan 09 13:11 so some of what I was talking about you already knew and I was not up to date on what you were actually looking to do. I will take a minute this morning and see if I can't sort this out.

Paul
 
OK, if I understand what you want here are some things to try.

In the On Load event for the Form get rid of the embedded macro and put this code.

Code:
Me.Recordsource = "Select * From tblContact Where tblContact.[ID] = 0"

This will open the form with no records visible.

In the Combobox, get rid of the code I gave you and put this in instead

Code:
Me.Recordsource = "Select * From tblContact Where tblContact.[Last Name] = '" & Me.ComboName & "'"

Now, if you want to clear the form of a record so that you go back to a blank form you can add a command button to the header area and put this in the click event

Code:
Call Form_Load()

And when you add people from outlook and you want to see them in your combobox right away, after the Run Command Action, add the Requery Action. That will requery the data in your combo box.

Try this stuff and post back with issues.

Paul
 
For the first one itsays the it cannot find the record source "Me
 
Okay now when i open it a small window will appear

Enter Parameter value
user name
_________
 
Sounds like some type of security level is being looked for. There is no field called user name (at least in my copy). I wonder if there was something in the embedded macro OpenArgs that is looking for a user name. Do you have a field in your table called User Name?

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top