Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem Opening Form from List Box Selection

Status
Not open for further replies.

Bronte1226

Technical User
Oct 18, 2002
123
US
I have a list box on a form that I am hoping will allow users to select the record from the box and it will open another form displaying the details of that record.

So far, I have been able to populate the list and get it to open the form I want it to successfully. The problem lies in linking the correct record.

When the record loads in the second form, the particular data field that I linked it with shows the correct information. However, it doesn't seem to be pulling the entire corresponding record's information. Nothing else is correct. What am I doing wrong?

Here is my code:
Private Sub List6_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Vendor Name] = '" & Me![List6] & "'"
Me.Bookmark = rs.Bookmark
End Sub

Private Sub OpenRecord_Click()
On Error GoTo Err_OpenRecord_Click

Dim strFormName As String
Dim stLinkCriteria As String

strFormName = "frm_vendor_name"
DoCmd.OpenForm strFormName, , , , , , Me.List6


Exit_OpenRecord_Click:
Exit Sub

Err_OpenRecord_Click:
MsgBox Err.Description
Resume Exit_OpenRecord_Click

End Sub


Beyond frustrated here! Please help!
 
How are you dealing with OpenArgs in frm_vendor_name ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
You don't suggest if there is any code in frm_Vendor_Name that uses OpenArgs.
I would change the code to something like:
Code:
Private Sub OpenRecord_Click()
    On Error GoTo Err_OpenRecord_Click

    Dim strFormName As String
    Dim stLinkCriteria As String

    strFormName = "frm_vendor_name"
    stLinkCriteria = "[Vendor Name] = '" & Me![List6] & "'"
    DoCmd.OpenForm strFormName, , , stLinkCriteria

        
Exit_OpenRecord_Click:
    Exit Sub

Err_OpenRecord_Click:
    MsgBox Err.Description
    Resume Exit_OpenRecord_Click
    
End Sub

Duane
Hook'D on Access
MS Access MVP
 
Thanks for the feedback!

dhookom, I actually had the form to use the OpenArgs, but this worked like a charm after I removed the OpenArgs, thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top