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

Refresh form for all users. 1

Status
Not open for further replies.

titans514

Programmer
Dec 4, 2002
13
0
0
US
Hi, I have a form that utilizes a listview controller, the form is used by three different users, i would like to have the information dynamically refreshed each time a user enters information. Any help is greatly appreciated.
 
One way to do this is to create a table that contains two date/time fields. The first date/time field would represent that a record was added or deleted from the "master" table. The send date/time field would indicate that a record, in the "master" table, was edited.

When your form opens, open the table and read in the 2 date/time fields and set them equal to public variables. In the OnTimer event of the form, check to see if either one of the date/time public variables are less than the ones in the table. If so, then either requery the form (if records were added/deleted) or refresh the form (if records were modified).

In the AfterInsert and AfterUpdate events of the form, you will need to update the table with the appropriate date/time values.

Example,

Table:
dtmRequery ... Date/Time field
dtmRefresh ... Date/Time Field

Form Module:

Dim mdtmRequery as Date
Dim mdtmRefresh as Date
Dim mrst as ADODB.Recordset

Sub Form_Open()

Open mrst and read 1st record

mdtmRequery = mrst!dtmRequery
mdtmRefresh = mrst!dtmRefresh

End Sub

Sub Form_Timer()

If (mdtmRequery < mrst!dtmRequery) And (Not Me.Dirty) Then
mdtmRequery = mrst!dtmRequery
Me.Requery

ElseIf (mdtmRefresh < mrstRI!dtmRefresh) And (Not Me.Dirty) Then
mdtmRefresh = mrstRI!dtmRefresh
Me.Refresh
End If

End Sub

Sub Form_AfterInsert()

mrst!dtmRequery = Now
mrst.UPDATE

mdtmRequery = mrstRI!dtmRequery

End Sub

Private Sub Form_AfterUpdate()

mrst!dtmRefresh = Now
mrst.UPDATE

End Sub
 
FancyPrairie,Thanks for the response will give it a try. Thanks again. Will let you know how it worked. titans
 
Worked like a charm, used a little different approach but the philosophy was the same. Thanx FancyPrairie.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top