March 26, 2011

Set label in MDI Form from table using Timer in visual basic

This is code sample to Set label in MDI Form on which label data taken from table using Timer in visual basic language.
 Dim rs As New Recordset  
 Private Sub MDIForm_Load()  
 open_recordset "select *from MASTER1 ", rs  
 MDIForm1.Top = 0  
 MDIForm1.Left = 0  
 MDIForm1.Width = Screen.Width  
 MDIForm1.Height = Screen.Height  
 End Sub  
 Private Sub MDIForm_Unload(Cancel As Integer)  
 Timer1.Enabled = False  
 rs.Close  
 End Sub  
 Private Sub Timer1_Timer()  
 While Not rs.EOF  
 If rs.Fields(0).Value = Format(Date, "dd/MM/yy") Then  
 myform(i).Label1 = rs.Fields(1).Value  
 myform(i).Show  
 End If  
 i = i + 1  
 rs.MoveNext  
 Wend  
 If Not rs.EOF Then  
 rs.MoveFirst  
 End If  
 Timer1.Enabled = False  
 End Sub