Microsoft Access 2000


          

Public Function funRestoreFormControls(frm As Form) As Boolean


Dim ctl As Control, rst As Recordset, dbs As Database, i As Integer

On Error GoTo 999 '

funRestoreFormControls = False '

Set dbs = CurrentDb '

Set rst = dbs.OpenRecordset("SELECT * FROM [-]")

If rst.RecordCount = 0 Then '

rst.Close '

Exit Function '

End If

With rst '

.MoveLast '

.MoveFirst ' 1

For i = 0 To .RecordCount - 1 '

Select Case rst!ControlType

Case acCommandButton '

Set ctl = appAccess.CreateControl(frm.Name, rst!ControlType, , "", "", rst!Left, rst!Top, rst!Width, rst!Height)

ctl.OnClick = "[Event Procedure]" '

ctl.Caption = rst!Caption '

ctl.ControlTipText = rst!ControlTipText '

Case acLabel '

Set ctl = appAccess.CreateControl(frm.Name, rst!ControlType, , "", rst!Caption, rst!Left, rst!Top, rst!Width, rst!Height)

ctl.BackColor = !BackColor '

Case acTextBox '

Set ctl = appAccess.CreateControl(frm.Name, rst!ControlType, , "", "", rst!Left, rst!Top, rst!Width, rst!Height)

ctl.SpecialEffect = 0 '

ctl.BorderColor = 0 '

ctl.BorderStyle = 1 '

Case acListBox '

Set ctl = appAccess.CreateControl(frm.Name, rst!ControlType, , "", "", rst!Left, rst!Top, rst!Width, rst!Height)