Select record from Subform (1 Viewer)

Gismo

Registered User.
Local time
Today, 17:34
Joined
Jun 12, 2017
Messages
1,298
Hi,

I have a subform with a user list
in the main form I want 3 controls
1 first control to show the first user in the list
2nd control to show the second user in the list
3rd control to show the 3rd user in the list

how would i code this please?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:34
Joined
May 7, 2009
Messages
19,233
you can add code to the Main Form's Current event.
make sure your textbox control names are in sequence.
example: Text1, Text2, Text3
Code:
Private Sub Form_Current()
    Dim rs As DAO.Recordset
    Dim i As Integer
    Set rs = Me.ThesubFormName.Form.RecordsetClone
    With rs
        If Not (.BOF And .EOF) Then
            .MoveFirst
        End If
        Do Until .EOF
            i = i + 1
            If i > 3 Then
                Exit Do
            End If
            Me("Text" & i) = !Product
            .MoveNext
        Loop
    End With
    Set rs = Nothing
End Sub
 

Gismo

Registered User.
Local time
Today, 17:34
Joined
Jun 12, 2017
Messages
1,298
you can add code to the Main Form's Current event.
make sure your textbox control names are in sequence.
example: Text1, Text2, Text3
Code:
Private Sub Form_Current()
    Dim rs As DAO.Recordset
    Dim i As Integer
    Set rs = Me.ThesubFormName.Form.RecordsetClone
    With rs
        If Not (.BOF And .EOF) Then
            .MoveFirst
        End If
        Do Until .EOF
            i = i + 1
            If i > 3 Then
                Exit Do
            End If
            Me("Text" & i) = !Product
            .MoveNext
        Loop
    End With
    Set rs = Nothing
End Sub
what refers to Product?

1596617346254.png

1596617217246.png
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:34
Joined
May 7, 2009
Messages
19,233
sorry, that was my test db.
is it the Email field you want to show on email1, email2 and email3?
 

Users who are viewing this thread

Top Bottom