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

OnMouseClick? 1

Status
Not open for further replies.

roles40

MIS
Aug 20, 2003
21
US
I am in need of help finding or developing code for OnMouseClick. I am pretty sure that there was a macro included in Access 97, but I am now using 2k. If anyone knows where it is, or has code for it, you would be greatly appreciated.
I am actually trying to use the OnMouseClick to send an email to myself when a database is updated while only having the user click one button. Any suggestions other than the OnMouseClick would be great.

Thanks,

Jamie
 
if the user is required to click a command button, use the _Click() event of the command button.

Private Sub CommandButton_Click()

You code here.

End Sub

Leigh Moore
LJM Analysis Ltd
 
Thanks Leigh! I was wrong, the OnMouseClick command is Java. My mistake.

Jamie
 
OK, I might have been a little premature in thinking that this problem was resolved. I am using access 2k and am trying to send an email to my email account whenever someone adds a record to the database.

I have this code:

<SCRIPT language=javascript event=onclick for=Command2>
href=&quot;mailto:me@mydomain.com?subject=MySubject&quot;>

</SCRIPT>

I still need to know how to put something in the body and send the email, through the default email program on the client pc. I don't want to have the email program pop up for the user to see, just to send the email. Anybody?

Thanks again,

Jamie
 
If you're using outlook as the email client its very simple and you won't need the Java script.

Paste this into a new module and use the Call function to execute the code.

Dim olApp As Object
Dim subject As String
Dim olMailItem
Dim newMail
Dim newRecipient
Dim mailBody As String

subject = &quot;Your text here&quot;
mailBody = &quot;A new record has been added to your database.&quot;

Set olApp = CreateObject(&quot;Outlook.Application&quot;)
Set newMail = olApp.CreateItem(olMailItem)
Set newRecipient = newMail.Recipients.Add(address)

With newMail
.subject = subject
.body = mailBody
End With

newMail.send

olApp.Quit
Set olApp = Nothing
Set newMail = Nothing
Set newRecipient = Nothing

If your not using outlook i honestly have no idea.

Leigh Moore
LJM Analysis Ltd
 
You'll need to change the following

Set newRecipient = newMail.Recipients.Add(address)

to

Set newRecipient = newMail.Recipients.Add(&quot;YourEmailAddress&quot;)



Leigh Moore
LJM Analysis Ltd
 
Leigh,
Works perfectly...you get a star.

Thanks so much for your help,

Jamie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top