Link to home
Start Free TrialLog in
Avatar of JOHNHO
JOHNHO

asked on

how do i set the database ?

like this i has 1 data control in my form and 3 text box.

i want to connect the data control to abc.mdb
and inside the abc.mdb therea 2 table
and i want to connect that data control to abc.mdb withe the table no 2 and also inside that table i has 3 field.
so i want my 3 text box to become that 3 field.

i know i can do it in the properties windows.

but now i want to do it manually in the code .

how ?

Avatar of SLE
SLE

Private Sub Form_Load()
    With Data1
        .DatabaseName = App.Path & "\abd.mdb"
        .RecordSource = "SELECT * FROM TheTable;"
        .Refresh
        .Recordset.MoveFirst
    End With
End Sub

Private Sub Data1_Validate(Action As Integer, Save As Integer)
    Text1 = Data1.Recordset.Fields(0)
    Text2 = Data1.Recordset.Fields(1)
    Text3 = Data1.Recordset.Fields(2)
End Sub


Avatar of JOHNHO

ASKER

thanks
ASKER CERTIFIED SOLUTION
Avatar of schworak
schworak

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
JOHNHO,

You should accept (or reject) someone's answer or comment - thanks is not enough   ;-)


SLE
same as above

except that
after connecting to database

'****
set text3.datasource = MyRecordSet

text3.datafield="FieldNameGoesHEre"