Use the Command Button Wizard, select Form Operations, Open Form in the next window, select the form you wan't to open, in the next window select "Open the form and find specific data to display".
In the next part of the Wizard, you specify which field in your current form to link with the form you open.
i tried that but cant get it to work...i explain again,the subform is showing a list of records,now i wan to add details to a specific record in the subform,i wan to open the form with the criteria of the choosen record...can it be done?
You want to open another form, based on a field(s) in the selected record (row) of a subform?
Private Sub fldName_DblClick(Cancel As Integer)
Dim strWhereCond as String
strWhereCond = "fldName1 = " & Me!fldName2"
DoCmd.OpenForm "frmName", , , strWhereCond
End Sub
fldName1 is the name of the field in the form to be opened
fldName2 is the corresponding equivalent field in the subform
So what did you call it in your subform? Replace fldName1 and fldName2 with the ACTUAL field names of your form. I didn't know what you called them so I made up the names. Is it 'id'.
the main form is to display a person information which includes his car number,then the subform is to display the number of traffic offences he has commits..
some of them has more than 1 offences.now i wan to open a form that is link with the record i selected in the subform so i can add a description to that particular offence..
the field which i wan to select is " Date_of_Offence "
the field in the form i wan to open is " Description "
they r from the same table..
if i didnt explain clearly pls ask me again,realli need help..thanks
OK. So you have a form, called 'frmOffences', say. It is bound to a table called 'tblOffences', say. The table has, among other fields, three fields called 'Date_of_Offence' and 'Description' and 'personID'.
You have a Main form called 'frmPerson', say. The PK is 'personID'. Within this form you have a subform, bound to the 'tblOffences' table, called 'Offences_subform', say. It is a datasheet view perhaps. It is linked to the Main form by 'personID'. This subform only shows certain fields from the 'tblOffences' table (to make it fit in the window).
Put this code behind the field 'Date_of_Offence' in the subform.
Private Sub Date_of_Offence_DblClick(Cancel As Integer)
Dim strWhereCond as String
strWhereCond = "Date_of_Offence = " & Me!Date_of_Offence & " AND personID = " & Me!personID
DoCmd.OpenForm "frmOffences", , , strWhereCond
Forms!frmOffences.Description.SetFocus
End Sub
If your PK is 'carNumber' then you will need to change 'personID' with 'carNumber'.
If that doesn't work then there is something that you are not telling me!
: )
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.