Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Small Challenge!

2 views
Skip to first unread message

perr...@yahoo.com

unread,
Aug 6, 2007, 5:04:24 PM8/6/07
to
It is like a mountain to me, but I am sure it is nothing to many of
your advanced Access Programmers here. Thanks for advance in helping
me out.

I need to do a "net send" command to active database users for a
message.

Is this possible with Access 2002?

say, user9000 is login, I can send all active login database users a
message sayin "the database will close in 1min".

thanks again.
Perry

Salad

unread,
Aug 6, 2007, 9:19:16 PM8/6/07
to
Look at
http://support.microsoft.com/kb/198755 to get a list of users in the app.

I don't know if the UserRoster displays the Windows user id (it displays
the machine name) or the login ID into the app. I suppose you could
create a table and use the function at
http://www.mvps.org/access/api/api0008.htm to stuff the user name and
login time to the app.

Ron Paii wrote to you on July 30th about NetSend.

paii, Ron

unread,
Aug 7, 2007, 8:19:59 AM8/7/07
to

<perr...@yahoo.com> wrote in message
news:1186434264....@g4g2000hsf.googlegroups.com...

I modified a function that reads the LDB file and returns a list of
computers with that MDB open. I also added a Shell call to send a message to
each computer.

'---------------------------------------
' Open a .ldb file and get list of users
' Sends a message to each user
' returns a list format for an "IN" clause of a query
'
Public Function UserListMsg(DBName As String, strMessage as String) As
String
On Error GoTo UserListMsgErr
Dim UserName As String, UserRight As String, UserList As String
Dim ldbName As String
Dim iNumUsers As Integer
ldbName = Left(DBName, Len(DBName) - 4)
ldbName = Trim(ldbName & ".ldb")
iNumUsers = 0
Open ldbName For Input Shared As #1
Do While Not EOF(1)
UserName = Input(31, #1)

' Send the message to computer
Shell("NET SEND " & UserName & " """ & strMessage & """")

iNumUsers = iNumUsers + 1
UserRight = Input(5, #1)
UserList = UserList & "'" & Trim$(UserName) & "',"
Loop
Close #1
UserListMsg = UserList
Exit Function
UserListMsgErr:
UserListMsg = ""
If Err = 53 Then '.ldb file not found
ElseIf Err = 62 Then
Close #1
Exit Function
Else
MsgBox Err.Number & " - " & Err.Description & ", Function: NumUsers"
End If
End Function


paii, Ron

unread,
Aug 7, 2007, 8:57:16 AM8/7/07
to

"paii, Ron" <no...@no.com> wrote in message
news:a6udnR2PPvg-_iXb...@athenet.net...

Sorry


Shell("NET SEND " & UserName & " """ & strMessage & """")

Should be
Shell("NET SEND " & Trim$(UserName) & " """ & strMessage & """")


perr...@yahoo.com

unread,
Aug 7, 2007, 10:45:34 AM8/7/07
to
Ron,
I tried the codes, it yields "5 - invalid procedure call or
argument, Function: NumUsers" error message.

P.S.: I am green in programming, in order for me to enable a button to
carry out the codes, I changed your code to a private sub, does that
matter?

Perry

paii, Ron

unread,
Aug 7, 2007, 11:11:32 AM8/7/07
to

<perr...@yahoo.com> wrote in message
news:1186497934.4...@o61g2000hsh.googlegroups.com...

Add these function to the module

Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenW" (ByVal
lpstring As Long) As Long

Private Function TrimNull(startstr As String) As String
TrimNull = Left$(startstr, lstrlen(StrPtr(startstr)))

End Function


perr...@yahoo.com

unread,
Aug 7, 2007, 11:25:27 AM8/7/07
to
Ron,
Thank you so much.

Perry

paii, Ron

unread,
Aug 7, 2007, 12:16:43 PM8/7/07
to

<perr...@yahoo.com> wrote in message
news:1186497934.4...@o61g2000hsh.googlegroups.com...
Forget my last posting, those 2 functions will not help. I inserted the
original function into a new MDB, commented out the SHELL call. It ran
without problem in the imediate window.

?UserListMsg("R:SYSTEM1.LDB","Test")

Step though the code and tell me which line failed.


perr...@yahoo.com

unread,
Aug 8, 2007, 10:09:17 AM8/8/07
to
Ron,
Thanks for your help again. I haven't have a chance to try
your method yet, but, I got one more question, does your codes send to
all active database users? Or to any users in the network?

Perry

perr...@yahoo.com

unread,
Aug 8, 2007, 10:26:59 AM8/8/07
to
Ron,
Never mind about my last question, but a more simplier one, how
do I call a public function to run with a button?

Perry

Larry Linson

unread,
Aug 8, 2007, 12:08:17 PM8/8/07
to
<perr...@yahoo.com> wrote

> Never mind about my last question, but a
> more simplier one, how do I call a public
> function to run with a button?

If you are not going to do anything with the returned value, you can just
put the function name preceded by an = sign in the Click event property of
the Button Control. Or you can create a code snippet that calls the
function.

Larry Linson
Microsoft Access MVP


0 new messages