Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / October 2005

Tip: Looking for answers? Try searching our database.

msgbox not working

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JOM - 19 Oct 2005 15:35 GMT
I got the following code somewhere, Cant remember where but I would like the
code to send a message to the employees that are logged on, to log out(that
is what the message contains) loggedon is the listbox that contains the list
of people loggedon.....

Private Sub Command1_Click()
Dim strUser As String
Dim i As Integer
Dim strMessage2Send As String
Dim strMessage As String
Dim RunBatch As Double

strMessage = Me.Message

For i = 0 To LoggedOn.ListCount - 1
   If LoggedOn.Selected(i) = True Then
   strUser = LoggedOn.Column(0, i)
   MsgBox Left(strUser, InStr(strUser, "--") - 1)
   strMessage2Send = strMessage2Send & "net send " & strUser & " """ & _
       strMessage & """" & Chr(13) & Chr(13)
   End If
Next
   If strMessage2Send = "" Then
       MsgBox "Please enter a computer name/user ID"
       
       Exit Sub
   End If
RunBatch = Shell(strMessage2Send, vbHide)
MsgBox "Message Sent"
End Sub
BruceM - 19 Oct 2005 16:26 GMT
For one thing, I think that Left(strUser, InStr(strUser, "--") - 1) needs to
be a string.  For another, you have defined strMessage2Send as itself plus
something else.  I don't see how that will work, but even if it does in some
way I can't picture, it will never be "" since it contains a text string.
Also, you need to End If before you Exit Sub.
Couldn't say about the RunBatch part.

>I got the following code somewhere, Cant remember where but I would like
>the
[quoted text clipped - 29 lines]
> MsgBox "Message Sent"
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.