PDA

Click to See Complete Forum and Search --> : Open a PWD Protected Access MDB


csdcom
Jan 9th, 2000, 12:08 AM
Any body got any ideas on how to do this once. I can already do it with a data control and use the following code, however it get a bit tedious when you have to do it all againg for another form etc

With Data1
.DatabaseName=App.Path & "\my.mdb"
.RecordSource="mytable"
.Connect=";Pwd=password"
.Refresh
End With

some form of function could be the answer but so far I have failed in getting one to work.

charlie

Clunietp
Jan 9th, 2000, 02:08 AM
Put this code into a module:

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:


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

csdcom
Jan 10th, 2000, 01:24 AM
Tom

Thanks for that I waS looking at it from a differenty angle. surprising what a fresh pair of eyse can do

Charlie