PDA

View Full Version : Open a SubForm to display required data



mdmackillop
01-04-2006, 06:35 AM
Hi All,
Best wishes for the New Year.
I've reached my limit on Access again!

I have a form ?Companies? which contains 2 subforms
Contact_SubForm

subContact



subContact is used as a ?lookup? and from a button on this form I want to open the record for the Company and the Contact. The record for the company on ?Companies? is opened by the code below. What I need help with is opening the subform to the correct record with the Contact details. The field Contact_No is used on Companies and Contact_Subform to link these, and on subContact to be used in the code.


Private Sub CommandShowDetail_Click()
On Error GoTo Err_CommandShowDetail_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Companies"

stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Parent!CommandCloseForm.Visible = True

Exit_CommandShowDetail_Click:
Exit Sub
Err_CommandShowDetail_Click:
MsgBox Err.Description
Resume Exit_CommandShowDetail_Click
End Sub

Killian
01-04-2006, 06:43 AM
Y'know Malc, I'm not entirely sure this belongs in the Outlook forum :whistle:

mdmackillop
01-04-2006, 07:20 AM
Ok I'm still in Happy Holiday mode! :bug: (Moved)