Use VBA to get a Bound Column from list box

tl mike

Registered User.
Local time
Today, 13:48
Joined
Sep 7, 2007
Messages
117
I am trying to set up a form in which I am able to dbl click on a product in a list box and it will take me to that product in a form associated to its product line.

This is what I have so far:

Dim stFrmName As String
Dim rs As Object

Set rs = stFrmName.Recordset.Clone
rs.FindFirst "PartNumberPK = " & Me.List30
stFrmName.Bookmark = rs.Bookmark


stFrmName = Forms!frmProductIndex!List30
DoCmd.OpenForm stFrmName

I get a compile error for the use of stFrmName for:

Set rs = stFrmName.Recordset.Clone
 

Attachments

I'm not sure about the design, but try

Code:
  Dim stFrmName     As String
  'Dim rs As Object

  '    Set rs = stFrmName.Recordset.Clone
  '    rs.FindFirst "PartNumberPK = " & Me.List30
  '    stFrmName.Bookmark = rs.Bookmark


  stFrmName = Forms!frmProductIndex!List30
  DoCmd.OpenForm stFrmName
 
Thanks for the reply but I am also trying to get it to open to the specific product that was selected which is where I am stuck. Getting it to open the correct form and then go to the the record selected.
 
Change your code to this:
Code:
Private Sub List30_DblClick(Cancel As Integer)
On Error GoTo Err_List30_DblClick
Dim stFrmName As String
Dim rs As Object
    stFrmName = Me.List30
    
    
    stFrmName = Forms!frmProductIndex!List30
    DoCmd.OpenForm stFrmName
    Set rs = Forms(stFrmName).Recordset.Clone
    rs.FindFirst "[PartNumberPK] = " & Me.List30.Column(0)
    Forms(stFrmName).Bookmark = rs.Bookmark
    
Exit_List30_DblClick:
    Exit Sub
Err_List30_DblClick:
    MsgBox Err.Description, , " GV Health"
    Resume Exit_List30_DblClick
End Sub
 

Users who are viewing this thread

Back
Top Bottom