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 to selected record on subform

Status
Not open for further replies.

jazminecat23

Programmer
Mar 16, 2007
103
US
hi all -

I have a form with a subform on it in datasheet view that lists the charges against a person. I need to open the ChargesDetail form based on what record is selected on the subform. This subform is on a tab. I have the button on the tab as well, just below the subform.

When I click the button, it says Microsoft Access cannot find the form ChargesDetail referred to in a macro expression or visual basic code.

Here is my code:

Code:
Private Sub cmdViewChargeDetail_Click()
On Error GoTo Err_cmdViewChargeDetail_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "ChargesDetail Form"
    
    stLinkCriteria = "[ChargeID]=" & Forms!ChargesDetail.[ChargeID]

    DoCmd.OpenForm stDocName, , , stLinkCriteria
    
Exit_cmdViewChargeDetail_Click:
    Exit Sub

Err_cmdViewChargeDetail_Click:
    MsgBox Err.Description
    Resume Exit_cmdViewChargeDetail_Click
    
End Sub

Can anyone help me? basically, when they highlight/select a record on the datasheet subform, and then click the button, I want to open the ChargesDetail form to display the details associated with that charge.
thanks in advance!



 
You may try this:
stLinkCriteria = "[ChargeID]=" & Me![ChargeID]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
If I do that, it says Microsoft Access cannot find the field ChargeID referred to in your expression.
 
it seems like somehow i need to capture the record ID of the highlighted/selected record on the subform datasheet, and pass that to the ChargeDetails form in the on open event?

 
Ooh oh, we're getting somewhere. that helped a lot. thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top