How to make a label or text box visiblt....

P

Paul

After executing an "Action" query like "Update", "Insert" or "Delete", the
default Access generated message saying "x record going to update" and "x
records successfuly updated", then the user need to click on the "OK" button
to close the message. I want to display a label or text box to notify the
user only about the outcome (no warning success or fail). If it fails I can
"trap" it with the same label or text box with differnt message. My question
is how to make the label or text box visible for 3 seconds and invisible
after then.
 
G

Guest

Hi Paul,

Here are a couple of examples that display the number of records affected
using a message box. It would be a fairly easy modification if you want to
open a form instead to display this information, and then automatically close
the form after 3 seconds.

Sub TestDAO()
' This method uses DAO. It requires a reference set to the
' Microsoft DAO 3.x Object Library (Access 97 --> 3.51, Access 2000+ --> 3.6).

On Error GoTo ProcError

Dim db As DAO.Database
Dim strSQL As String

Set db = CurrentDb()
strSQL = "UPDATE tblEmployees SET tblEmployees.City = ""Lynnwood"""

db.Execute strSQL, dbFailOnError
MsgBox db.RecordsAffected & " records were updated.", vbInformation, _
"Your message box title goes here"

ExitProc:
' Cleanup
On Error Resume Next
db.Close : set db=Nothing
Exit Sub
ProcError:
MsgBox "Error: " & Err.Number & ". " & Err.Description, _
vbInformation, "Error in TestDAO Procedure..."
Resume ExitProc
End Sub



Sub TestADO()
' This method uses ADO. It requires a reference set to the Microsoft ActiveX
' Data Objects 2.x Library (2.1 is the default library for Access 2000).

On Error GoTo ProcError

Dim strSQL As String
Dim lngRecordsAffected As Long

strSQL = "UPDATE tblEmployees SET tblEmployees.City = ""Bellevue"""

CurrentProject.Connection.Execute strSQL, lngRecordsAffected, adCmdText

MsgBox lngRecordsAffected & " records were successfully updated.",
vbInformation

ExitProc:
Exit Sub
ProcError:
MsgBox "Error: " & Err.Number & ". " & Err.Description, _
vbInformation, "Error in TestADO Procedure..."
Resume ExitProc
End Sub


Note: In both cases, you can substitute a saved action query for strSQL in
the above examples, ie.:

CurrentProject.Connection.Execute "qupdPrices", lngRecordsAffected, adCmdText


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top