Select listbox and open form (1 Viewer)

Onlylonely

Registered User.
Local time
Today, 11:22
Joined
Jan 18, 2017
Messages
43
Hi Guys,

Need help on this. I have a listbox and i want it to open a form with all the data when i select particular item in the listbox.

P/S: I'm able to open a form but is without the information. I wish to pull all the information from the table and fill into the form.

Advice and help is appreciated. Please refer to attachment.
 

Attachments

  • vendor.accdb
    1.2 MB · Views: 67

Ranman256

Well-known member
Local time
, 23:22
Joined
Apr 9, 2015
Messages
4,337
the info form is not connected.
set the recordsource of the form to tGuests.

on the VendorList form:
the LIST box must be bound to col 1, the GuestId

in the button click event,
filter the form to show that 1 guest...

Code:
Private Sub openbtn_Click()
  DoCmd.OpenForm "Info",,,"[GuestID]=" & me.List0
end sub
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:22
Joined
May 7, 2009
Messages
19,249
as ranman said you need to bound the Info
form.

if the intention is just to display the
info and not to update it, and still
you want it unbound, set the column count
of your listbox to 8. the width to 5,
the column widths to 1;1;0;0;0;0;0;0.

on the click event of the button:
Code:
Private Sub openbtn_Click()

Dim RowNumber As Integer
RowNumber = Me.List0.ListIndex + 1

On Error Resume Next
DoCmd.Close acForm, "Info"

DoCmd.OpenForm "Info"
If Me.List0.ListIndex > -1 Then
    With Forms!info
        !txtfn = Me.List0.Column(1)
        !txtln = Me.List0.Column(2)
        !txtem = Me.List0.Column(3)
        !txtct = Me.List0.Column(4)
        !txtph = Me.List0.Column(7)
        !txtadd = Me.List0.Column(5)
    End With
End If

End Sub
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:22
Joined
May 7, 2009
Messages
19,249
as ranman said you need to bound the Info
form.

if the intention is just to display the
info and not to update it, and still
you want it unbound, set the column count
of your listbox to 8. the width to 5,
the column widths to 1;1;0;0;0;0;0;0.

on the click event of the button:
Code:
Private Sub openbtn_Click()

Dim RowNumber As Integer
RowNumber = Me.List0.ListIndex + 1

On Error Resume Next
DoCmd.Close acForm, "Info"

DoCmd.OpenForm "Info"
If Me.List0.ListIndex > -1 Then
    With Forms!info
        !txtfn = Me.List0.Column(1)
        !txtln = Me.List0.Column(2)
        !txtem = Me.List0.Column(3)
        !txtct = Me.List0.Column(4)
        !txtph = Me.List0.Column(7)
        !txtadd = Me.List0.Column(5)
    End With
End If

End Sub
 

Onlylonely

Registered User.
Local time
Today, 11:22
Joined
Jan 18, 2017
Messages
43
Thanks Ranman256 and arnelgp !!!
Appreciate your help on this
 

Users who are viewing this thread

Top Bottom