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

VBA Novice Needs Help

Status
Not open for further replies.

JJman

Technical User
May 8, 2003
89
IN
I'm still very "wet behind the ears" when it comes to VBA, but could someone please tell me what's wrong with my code? This procedure is designed so that, if users attempt to open the database before 7:30 am, thus opening the switchboard, it will tell them they aren't allowed in, send me an email telling me they tried to enter, and shut it down. It is giving me the runtime error I put below the code...

Private Sub Form_Load()
If Me.Time < #7:30:00 AM# And Me.Time > #4:00:00 AM# Then
MsgBox &quot;You are not allowed in the database before 7:30 a.m.&quot;
DoCmd.SendObject , &quot;&quot;, &quot;&quot;, &quot;[my email address]&quot;, &quot;&quot;, &quot;&quot;, &quot;Unauthorized Database Entry&quot;, &quot;Auto Message: The person from whom this message was sent attempted to enter the database at a time reserved for administration.&quot;, False, &quot;&quot;
DoCmd.Quit

End If
End Sub

This gives &quot;runtime error 2293. [Database name] can't send a message for the reason stated in the preceding alert.&quot; What &quot;preceding alert&quot; it's talking about I haven't the foggiest idea. Anyway, any help is appreciated.






 
Hi

When yoy are using SendObject, and do not wish to actually send an object, just a message I think you need to specify that so:

DoCmd.SendObject , acSendNoObject, &quot;&quot;, &quot;[my email address]&quot;, &quot;&quot;, &quot;&quot;, &quot;Unauthorized Database Entry&quot;, &quot;Auto Message: The person from whom this message was sent attempted to enter the database at a time reserved for administration.&quot;, False, &quot;&quot;


Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
I only tried this method for the first time yesterday, so I've still got some learning to do about it - and really don't know what caused the message you got.

However, a couple notes on the code above:
1) put the acSendNoObject before the first comma, (it's in the ObjectName position above);
2) put acFormatText after the second comma, (the OutputFormat parameter; if unspecified, you'll be prompted).


Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top