drilling down on a subform created from a query.

  • Thread starter Thread starter Paul Wheeler
  • Start date Start date
P

Paul Wheeler

I have created a form subform to display the results of a
query which only contain some of the detail; an overview.
i want to be able to click one of the abreviated records
in the subform and bring up the complete complete record.

i already have a form that shows the completed record but
am not sure where to go from here?

regards, Paul
 
Hi,
You use your primary key (whatever field that might be) to open up the form
to the correct record. In other words, you have a form that shows all records
but you use the wherecondition argument of the OpenForm method to only
show the one you are interested in.

So let's say your pk is a field called recId.
When you click on the record in the subform, this code should run:

DoCmd.OpenForm "theOtherForm",,,"recId = " & Me.txtrecId

Obviously the field recId must be in both the subform's recordset and
the other form's recordset.
Just substitute your actual names in the code above.
 
thanks for the response, but im a bit of a novice when it
comes to code, this is what i did:

In the code part of the SubForm:

Private Sub onclick()

DoCmd.OpenForm "frmMain",,,"Id = " & Me.txtId

End Sub

I also tried to put this code in the form that holds the
subform unfortunately nothing happended when i clicked on
a record...

Id is my Primary Key in my table that frmMain draws on.
the Primary Key is also included in my query and is
displayed in my subform....grateful for some more
guidance....
Paul

-----Original Message-----
Hi,
You use your primary key (whatever field that might be) to open up the form
to the correct record. In other words, you have a form that shows all records
but you use the wherecondition argument of the OpenForm method to only
show the one you are interested in.

So let's say your pk is a field called recId.
When you click on the record in the subform, this code should run:

DoCmd.OpenForm "theOtherForm",,,"recId = " & Me.txtrecId

Obviously the field recId must be in both the subform's recordset and
the other form's recordset.
Just substitute your actual names in the code above.

--
HTH
Dan Artuso, Access MVP


"Paul Wheeler" <[email protected]> wrote in
message news:[email protected]...
 
Hi,
Do you get an error?
What is the name of the control on your subform that displays
Id? Going by your code, it should be called txtId.

The other thing is you probably should put the code in the DoubleClick event
of one of the controls on the subform. If you have in the Click event of the form itself,
I don't think it will fire if you click on any of the text boxes.

So, put that line of code in one the text boxes DoubleClick event and try it out.
You could also put this line in to test:

MsgBox Me.txtId
DoCmd.OpenForm "frmMain",,,"Id = " & Me.txtId

Once again, make sure you have the correct name for the text box that displays
your Id.
 
Back
Top