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

Open record in subform by linking criteria 1

Status
Not open for further replies.

naoaja

Technical User
Aug 27, 2004
48
US
I have a form based on a query. The PK = IDMess. I want to be able to click on one of the records in that form and have it open another form/subform (Messages)/(MessagesTemp) and open to a record (in MessagesTemp) that also contains IDMess.

I can get it to open to the subform, but I can't get it to link properly.

Any help appreciated.
Thanks
 
How about putting something like this on the subform:
Code:
Private Sub IDMess_DblClick()
If Not IsNull(Me.IDMess) Then
'Assuming IDMess is numeric
    DoCmd.OpenForm "Table3Sub", , , "IDMess=" & Me.IDMess
End If
End Sub

Can I suggest Double Click? On Click can be a nuisance.
 
Thanks for the reply! The above code works great to open the subform to the correct message. How can I get it to open the form and subform together?

 
Sorry, I did not read your post carefully [blush]. How is the Messages form related to MessagesTemp? Could you use something like (typed, not tested):

Code:
Private Sub IDMess_DblClick()
If Not IsNull(Me.IDMess) Then
'Assuming IDMess is numeric
    intMessageID=Dlookup("MessageID","tblMessagesTemp","IDMess=" & Me.IDMess)
    DoCmd.OpenForm "frmMessagesMTemp", , , "MessageID=" & intMessageID
'Perhaps some recordsetclone / bookmark stuff for correct IDMess
End If
End Sub
 
Thanks for getting me to think in another direction. I ended up changing the relationship between the form and subform and it works great. Thanks also for the reminder of double click vs single.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top