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

Open Subform to Same Record As Main Form - Source For Both is Same Table 1

Status
Not open for further replies.

shelby55

Technical User
Jun 27, 2003
1,229
CA
Hello

I am using Access 2010. I have a table of data for patient transfers. I have a different form depending on the transfer type and not all cases will require a nurse for the transport but all will require cost information.

The db was created by someone else and I don't want to change too much but I would like to build a button on the main form that would open up another form that would allow me to enter the nurse information on one new form and the cost information on another.

I can't seem to get this to work where when the subreport opens it is for the same record as the main report. The code currently that isn't working:
Code:
 Private Sub cmdCaseCost_Click()
    DoCmd.RefreshRecord
    DoCmd.OpenForm "subfrmCaseCost", acNormal, , ID_Number = Me.[txtID], , acDialog
End Sub

Note that the user can either enter a new record or be editing an existing. I mention that because I originally had code so that it saved the record first because I thought the issue might be that the record wasn't saved yet to show up in the subform but if I exit out of the main form and check the table, the record was saved. If I put the docmd to save the record, it gives me an error if it's not a new record.

Thanks.
 
DoCmd.OpenForm "subfrmCaseCost", acNormal, , [!]"[/!]ID_Number = [!]" & [/!]Me.[txtID], , acDialog

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hey

Thanks so much, PHV! It wasn't working abut I wasn't getting any error messages either. This worked as I'm sure you knew it would!

Thanks again.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top