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

Function Hangs up on the third record?

Status
Not open for further replies.

Ammodog

Technical User
Dec 13, 2002
97
US
I have table with the Login ID and a message field. I have a form with a command button that calls this function but when the code is executed it only runs down to the third record and then quits. Anyone have any ideas??


Function Send()
Dim rst As DAO.Recordset
Dim i As Integer, NumRec As Integer
'create a recordset from your table
Set rst = CurrentDb.OpenRecordset("tblMsgBank")

'create a counter for the loop (i)
'the index starts at 0 for the 1st record
'Start the loop
With rst
.MoveLast
NumRec = .RecordCount
.MoveFirst
For i = 0 To NumRec - 1
Shell ("net send " & !LoginID & " " & !Message & "")
DoEvents
.MoveNext
Next i
End With
rst.Close
Set rst = Nothing

End Function

Christopher Abney
"There is no limit to the good you can do if you dont care who gets the credit"
[Afro]
 
there is something wrong with the third record. A null value etc.
 
Why are you using a For Next loop? Seems like
Set rst = CurrentDb.OpenRecordset("tblMsgBank")

With rst

Do

Shell ("net send " & !LoginID & " " & !Message & "")
DoEvents
.MoveNext

loop until .eof

end with
would be a lot more efficient
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top