I have one table - tblMAIN
I have 4 ID Fields - mainID, FatherID, MotherID and FullName
1 Form - frmMAIN
1 Combo Box - cboMAIN
2 Text Boxes - txtFATHER, txtMOTHER
I am trying to write a SQL statement in VBA that will select a record in the combo box cboMAIN and by doing that selection, two text boxes are populated.
Robert is selected in the cboMAIN, Robert has a MainID of 20
Robert mother is Ruth, she has a MainID of 30
Robert's father's MainID is 40
So in txtFather it will display record 40 / FullName and in txtMother it will display FullName for record MainID30.
I would like to add text fields and show Ruth's mother and Robert's father's father.
Here is an idea I have, but not sure what to do next.
Dim sqlME As String
Dim sqlFATHER As String
Dim db As Database
Dim rs As DAO.Recordset
sqlFATHER = "SELECT * FROM tblMAIN WHERE MainID = " & Forms![MAIN]![cboMAIN] & ";"
'AND NOT SURE WHAT I NEED TO DO HERE!
Set db = CurrentDb
Set rs = db.OpenRecordset(sqlFATHER)
Me.txtFather.Value = rs!FullName
Set rs = Nothing
Set db = Nothing