Hi All,
Merry Christmas. I am having a problem with vba code in access form. I
am trying to autopoulate fields on form from the table in access. I have code that is running good for the selected table I mention in my code given below
Private Sub Form_Load()
Dim con As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim sSQL As String
sSQL = "SELECT * FROM client"
Set con = CurrentProject.Connection
rst.Open sSQL, con
Do While Not rst.EOF
Me.label1 = rst.Fields(0).Name
Me.label2 = rst.Fields(1).Name
Exit Do
Loop
rst.Close
con.Close
Set rst = Nothing
Set con = Nothing
End Sub
The table mentioned is Client and the form fields will populate all the columns of this table only. now I want the form to auto populate fields from the table that I select in the database, inshort I want to keep table selection part in the code dynamic. PLEASE HELP.