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

open form from subform help..

Status
Not open for further replies.

jonra

Programmer
Jul 20, 2003
42
SG
i wan to open a form using selected id in a subform as criteria....how can i do it?...thanks
 
Hi!

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.

HTH Roy-Vidar
 
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
 
i use ur codes but it say i cant find fldName2..
 
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'.
 
wat i mean is it cant find that field...not cant find fldName2..i hav alreadi change it to the field i wan to find..the field is in the subform
 
You can't find it or the computer can't find it ? Which ?
 
What is the name of the field in the subform that you want to use as the criteria for opening the other form?

Is it called 'id' ? Or is it called something else?

Is it bound to any table?
 
i tink i explain from the start...

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!
: )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top