help with linking subforms together

antidote

New member
Local time
Today, 08:54
Joined
Sep 23, 2008
Messages
6
Hello. I have a form which I am using to create a pseudo search engine for my database. Users enter search criteria via unbound text boxes. The information the user enters is sent to a query to search my database for records. results are displayed in a datasheet view in a subform. (which is essentially showing the query results)

I would like to be able to click a record in the subform datasheet, and have additional information about that record (fields) appear on the form.

any ideas?
 
You can always put a double-click event on the subform and then open detail form using link criteria

e.g.


Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourDetailForm"

stLinkCriteria = "[RecordID]=" & "'" & Me![MyTextBox1] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria


Another approach is to put a list box instead of a subform and load search query in to it. Then put the same above code on double-click event of the listbox



Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourDetailForm"

stLinkCriteria = "[RecordID]=" & "'" & Me![MySearchList] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria


Note: The above search code is assuming that te record id is a text field.
Hope it gets you started
 
I am not exactly sure where I would put that code. Here is the code in my subform right now. Thank you for your help, it is greatly appreciated.

Option Compare Database

Private Sub cmdCancel_Click()
DoCmd.Close acForm, "SEARCH"
End Sub

Private Sub cmdOK_Click()
Forms![SEARCH]![SEARCHSUB].Requery

Forms![SEARCH]![SEARCHSUB2].Requery
End Sub

Private Sub SEARCHSUB_Current()
DoCmd.RunCommand acCmdSelectRecord
End Sub

Private Sub Form_Load()

End Sub

Private Sub Form_Open(Cancel As Integer)

End Sub
 
SEARCH is my form. SUBSEARCH is my datasheet view subform. SUBSEARCH2 is my second subform where i wish the description to be.
 
Can anyone please steer me in the right direction?
thanks
 

Users who are viewing this thread

Back
Top Bottom