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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open detail form to selected entry from previous form

Status
Not open for further replies.

talbotlives

Technical User
Jul 14, 2005
7
US
Dear Access deities,
I have a search form that returns all of its results in a continuous form. From there, the user needs to be able to select one of the result rows and open the detail form to that entry (I have the detail form linked as a button now, but I cant figure out how to get it to open to the selected entry)

form names: searchform, searchresultsform, resultsdetailform

(I am new to access and just started learning vb last week, so please pity my ignorance and spell out any help as much as possible). Thanks in advance

-Talbot
 
Search for help on DoCmd.OpenForm. Pay particular attention to the Where Condition and OpenArgs sections.


Randy
 
Randy700
Thank you very much for your rapid reply. Here is what I have so far. I think I need to be able to set the current record (lngrecordnum) equal to the corresponding record number in the detail form (??? now) that is opening. Any thoughts?

Code:
Sub CurrentFormRecord(frm As Form)
    Dim lngrecordnum As Long

    lngrecordnum = frm.CurrentRecord
End Sub

Private Sub viewsearchresultdetails_Click()
On Error GoTo Err_viewsearchresultdetails_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "DetailInfoForm"
    DoCmd.OpenForm stDocName, WhereCondition:="(lngrecordnum = ??? )"


Exit_viewsearchresultdetails_Click:
    Exit Sub

Err_viewsearchresultdetails_Click:
    MsgBox Err.Description
    Resume Exit_viewsearchresultdetails_Click
 
Maybe if you change...
DoCmd.OpenForm stDocName, WhereCondition:="(lngrecordnum = ??? )"
to this...
DoCmd.OpenForm stDocName, , ,"lngrecordnum = " & Variable or Textbox containing the number


Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top