I am "creating" my first loop, I copied code and am trying to get it to work. I have the loop functioning but when I try to do a Dlookup in the middle of the loop it does not work.

I am sure there are some ways to make this code work better, Just trying to retrieve dynamic data for the body of my email.

Here is the relevant part of the loop.

```
strSQL = "SELECT * FROM emailbody Where EmailMainID = " & Me.EmailMainID

Set rs = CurrentDb.OpenRecordset(strSQL)

With rs
    If Not .BOF And Not .EOF Then

            .MoveLast
            .MoveFirst

            While (Not .EOF)
                LookupInfo = rs.Fields("beforetable") & "-" & rs.Fields("beforefield") 'Get Table and Field to lookup
                LookupLen = Len(LookupInfo) 'Find how many letters are in the string
                SubtractLen = InStr(1, [LookupInfo], "-") ' Find the number of letters to the left
                RightCut = LookupLen - SubtractLen ' Find how many are to the right
                Table = Left([LookupInfo], InStr(1, [LookupInfo], "-") - 1) ' Set the table value
                Field = Right([LookupInfo], RightCut) ' Set the Field Value
                InfoInsert = DLookup("Table", "Field", TeamDetailsID = 39)
                FreshData = rs.Fields("emailbodyid") & " " & rs.Fields("bodycontent") 

                LongEmail = EmailMe & FreshData
                EmailMe = LongEmail
                FreshData = ""
                LongEmail = ""

              .MoveNext
            Wend

        End If

        .Close

    End With

```