|
tech
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Syntax to refer to a control on a subform.Hi, I have (below) some code that opens a form(FrmRecUpdate) based on the
selected PatientNo in another form called FrmClinic1sub. 'DoCmd.OpenForm "FrmRecUpdate", , , "[PatientNo] = Forms![FrmClinic1Sub]![PatientNo]" This works fine when the form FrmClinic1Sub is opened as a standalone form. However it needs to open as a Subform, contained within a form called FrmClinic1. When I amend the code to account for the fact that FrmClinic1Sub is now a subform, it fails. My new code is partly derived from the help screen, and from the original code, suggested by Rowiga DoCmd.OpenForm "FrmRecUpdate", , , "PatientNo = Forms!FrmClinic1.FrmClinic1sub.Form!Controls.PatientNo" Am I making a mistake, or is this action not possible from a subfrom? Thank you, Tim It is possible.
If the code is in the context of FrmClinic1Sub and [PatientNo] is a numeric Field or a Control bound to a numeric Field, use: DoCmd.OpenForm "FrmRecUpdate", , , "[PatientNo] = " & Me.[PatientNo] -- Show quoteHTH Van T. Dinh MVP (Access) "Timboo" <Tim***@discussions.microsoft.com> wrote in message news:30453341-C648-4516-9F35-A5B3798CB7D4@microsoft.com... > Hi, I have (below) some code that opens a form(FrmRecUpdate) based on the > selected PatientNo in another form called FrmClinic1sub. > > 'DoCmd.OpenForm "FrmRecUpdate", , , "[PatientNo] = > Forms![FrmClinic1Sub]![PatientNo]" > > This works fine when the form FrmClinic1Sub is opened as a standalone form. > However it needs to open as a Subform, contained within a form called > FrmClinic1. When I amend the code to account for the fact that FrmClinic1Sub > is now a subform, it fails. My new code is partly derived from the help > screen, and from the original code, suggested by Rowiga > > DoCmd.OpenForm "FrmRecUpdate", , , "PatientNo = > Forms!FrmClinic1.FrmClinic1sub.Form!Controls.PatientNo" > > Am I making a mistake, or is this action not possible from a subfrom? > > Thank you, Tim > > > > > Van T.
Thank you, will try this later today, and thank you for your other post too. Does the code below only work on numerical fields, as the PatientNo is actually text, since the patient number, although a number also has the first initials of the hospital infront. Thank you Tim. Show quote "Van T. Dinh" wrote: > It is possible. > > If the code is in the context of FrmClinic1Sub and [PatientNo] is a numeric > Field or a Control bound to a numeric Field, use: > > DoCmd.OpenForm "FrmRecUpdate", , , "[PatientNo] = " & Me.[PatientNo] > > -- > HTH > Van T. Dinh > MVP (Access) > > > > > "Timboo" <Tim***@discussions.microsoft.com> wrote in message > news:30453341-C648-4516-9F35-A5B3798CB7D4@microsoft.com... > > Hi, I have (below) some code that opens a form(FrmRecUpdate) based on the > > selected PatientNo in another form called FrmClinic1sub. > > > > 'DoCmd.OpenForm "FrmRecUpdate", , , "[PatientNo] = > > Forms![FrmClinic1Sub]![PatientNo]" > > > > This works fine when the form FrmClinic1Sub is opened as a standalone > form. > > However it needs to open as a Subform, contained within a form called > > FrmClinic1. When I amend the code to account for the fact that > FrmClinic1Sub > > is now a subform, it fails. My new code is partly derived from the help > > screen, and from the original code, suggested by Rowiga > > > > DoCmd.OpenForm "FrmRecUpdate", , , "PatientNo = > > Forms!FrmClinic1.FrmClinic1sub.Form!Controls.PatientNo" > > > > Am I making a mistake, or is this action not possible from a subfrom? > > > > Thank you, Tim > > > > > > > > > > > > > If it is Text, you need to use:
DoCmd.OpenForm "FrmRecUpdate", , , _ "[PatientNo] = '" & Me.[PatientNo] & "'" -- Show quoteHTH Van T. Dinh MVP (Access) "Timboo" <Tim***@discussions.microsoft.com> wrote in message news:BB852BE1-D357-46A6-BA41-0EFE10E9BE2E@microsoft.com... > Van T. > > Thank you, will try this later today, and thank you for your other post too. > Does the code below only work on numerical fields, as the PatientNo is > actually text, since the patient number, although a number also has the first > initials of the hospital infront. > > Thank you Tim. > > |
|||||||||||||||||||||||