Put this code into a module:
Code:
Public Sub PopulateDataControlProperties(dataControl As Control, Recordsource As String)
With dataControl
.DatabaseName = "nwind.mdb"
.Recordsource = Recordsource
.Connect = ";Pwd=password"
.Refresh
End With
End Sub
and put this into the Form_Load event of the form with the data control:
Code:
Private Sub Form_Load()
PopulateDataControlProperties Data1, "Customers"
End Sub
There are few different ways you can do it, but this will automatically populate the data control that you specify with the correct parameters and you can choose your recordset too....
HTH
Tom