izanagi21 0 Newbie Poster

Hi, im a newbie so please go easy on me. I'm trying to create a multilevel marketing system with access database but with 8 levels only per account of a member. I'm kinda stuck on adding profit to different (chain) upline accounts when adding a member. I can't seem to figure out what to do, it needs to search the upline's account on every level and then add their respective profit when adding a downline.

con.Open()
        Dim rs As New OleDbCommand("Select * from tbl_Profit where MemberNo='" & txtUpMem.Text & "', AND AccountNo='" & txtUpAcc.Text & "'", con)
        rea = rs.ExecuteReader
        While rea.Read
            inprofit1 = rea(3)
        End While
        con.Close()
        upline1 = txtUpMem.Text
        upprofit1 = Val(inprofit1) + 20
        con.Open()
        Dim update As New OleDbCommand("UPDATE tbl_Profit set Profit='" & upprofit1 & "' where MemberNo='" & txtUpMem.Text & "', AND AccountNo='" & txtUpAcc.Text & "'", con)
        update.ExecuteNonQuery()
        con.Close()

this is my code on level 1, upline1 is this 1's upline then updating it in the table

con.Open()
        Dim rs1 As New OleDbCommand("Select * from tbl_Profit where MemberNo='" & upline1 & "'", con)
        rea = rs.ExecuteReader
        While rea.Read
            inprofit2 = rea(3)
        End While
        con.Close()
        upprofit2 = Val(inprofit2) + 20
        con.Open()
        Dim update1 As New OleDbCommand("UPDATE tbl_Profit set Profit='" & upprofit2 & "' where MemberNo='" & upline1 & "'", con)
        update.ExecuteNonQuery()
        con.Close()

this is level 2, (up to level 8 so i wont bother adding the rest) same approach.

any thoughts on what i should do next? also how can i count the records within the table filtered with the upline's member no. then if it is alrdy 5 records the system will trap it? thanks in advance :D