Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Open form criteria set for two records

Discussion in 'Information Technology' started by SAC, Jul 28, 2006.

  1. SAC

    SAC
    Expand Collapse
    Guest

    I'm trying to click a button on a form and open another form. Based on the
    criteria, the 2nd form should show 1 of 2 records.

    Right now I have:

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmTWDHPH"

    stLinkCriteria = "[PHORD]=" & Forms![frmLookup]![frmLookup
    subform]![TXTXTPO]

    DoCmd.OpenForm stDocName, , , stLinkCriteria

    This should show 2 records, but when I run this I get the error: "The
    OpenForm action was cancelled."

    What can I do to get this to run?

    Thanks.
     
  2. Loading...


  3. schasteen

    schasteen
    Expand Collapse
    Guest

    Looks like you are trying to use a field from a subform, in which case your
    criteria should be
    stLinkCriteria = "[PHORD]=" &
    Forms![frmLookup]![frmLookupsubform].form![TXTXTPO]


    "SAC" wrote:

    > I'm trying to click a button on a form and open another form. Based on the
    > criteria, the 2nd form should show 1 of 2 records.
    >
    > Right now I have:
    >
    > Dim stDocName As String
    > Dim stLinkCriteria As String
    >
    > stDocName = "frmTWDHPH"
    >
    > stLinkCriteria = "[PHORD]=" & Forms![frmLookup]![frmLookup
    > subform]![TXTXTPO]
    >
    > DoCmd.OpenForm stDocName, , , stLinkCriteria
    >
    > This should show 2 records, but when I run this I get the error: "The
    > OpenForm action was cancelled."
    >
    > What can I do to get this to run?
    >
    > Thanks.
    >
    >
    >
     
  4. SAC

    SAC
    Expand Collapse
    Guest

    I changed it to this and still get the same error:

    Thanks for your help.

    I changed it to this and still get the same error:

    stDocName = "frmTWDHPH"

    stLinkCriteria = "[XCPO]=" & Forms![frmLookup]![frmLookup
    subform].Form![txtXCPO]

    DoCmd.OpenForm stDocName, , , stLinkCriteria

    "schasteen" <schasteen@discussions.microsoft.com> wrote in message
    news:30706918-0CAF-4028-91B6-003C72DBCE7D@microsoft.com...
    > Looks like you are trying to use a field from a subform, in which case

    your
    > criteria should be
    > stLinkCriteria = "[PHORD]=" &
    > Forms![frmLookup]![frmLookupsubform].form![TXTXTPO]
    >
    >
    > "SAC" wrote:
    >
    > > I'm trying to click a button on a form and open another form. Based on

    the
    > > criteria, the 2nd form should show 1 of 2 records.
    > >
    > > Right now I have:
    > >
    > > Dim stDocName As String
    > > Dim stLinkCriteria As String
    > >
    > > stDocName = "frmTWDHPH"
    > >
    > > stLinkCriteria = "[PHORD]=" & Forms![frmLookup]![frmLookup
    > > subform]![TXTXTPO]
    > >
    > > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > >
    > > This should show 2 records, but when I run this I get the error: "The
    > > OpenForm action was cancelled."
    > >
    > > What can I do to get this to run?
    > >
    > > Thanks.
    > >
    > >
    > >
     
  5. schasteen

    schasteen
    Expand Collapse
    Guest

    Is [XCPO] text? if so use
    stLinkCriteria = "[XCPO]= '" &
    Forms![frmLookup]![frmLookupsubform].Form![txtXCPO] &"'"

    "SAC" wrote:

    > I changed it to this and still get the same error:
    >
    > Thanks for your help.
    >
    > I changed it to this and still get the same error:
    >
    > stDocName = "frmTWDHPH"
    >
    > stLinkCriteria = "[XCPO]=" & Forms![frmLookup]![frmLookup
    > subform].Form![txtXCPO]
    >
    > DoCmd.OpenForm stDocName, , , stLinkCriteria
    >
    > "schasteen" <schasteen@discussions.microsoft.com> wrote in message
    > news:30706918-0CAF-4028-91B6-003C72DBCE7D@microsoft.com...
    > > Looks like you are trying to use a field from a subform, in which case

    > your
    > > criteria should be
    > > stLinkCriteria = "[PHORD]=" &
    > > Forms![frmLookup]![frmLookupsubform].form![TXTXTPO]
    > >
    > >
    > > "SAC" wrote:
    > >
    > > > I'm trying to click a button on a form and open another form. Based on

    > the
    > > > criteria, the 2nd form should show 1 of 2 records.
    > > >
    > > > Right now I have:
    > > >
    > > > Dim stDocName As String
    > > > Dim stLinkCriteria As String
    > > >
    > > > stDocName = "frmTWDHPH"
    > > >
    > > > stLinkCriteria = "[PHORD]=" & Forms![frmLookup]![frmLookup
    > > > subform]![TXTXTPO]
    > > >
    > > > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > > >
    > > > This should show 2 records, but when I run this I get the error: "The
    > > > OpenForm action was cancelled."
    > > >
    > > > What can I do to get this to run?
    > > >
    > > > Thanks.
    > > >
    > > >
    > > >

    >
    >
    >
     
  6. SAC

    SAC
    Expand Collapse
    Guest

    AWESOME!! Thanks!

    I knew better, but need another pair of eyes!

    Thanks a bunch!!!

    "schasteen" <schasteen@discussions.microsoft.com> wrote in message
    news:45C1F73E-AD08-48E8-A86D-53BE970C0724@microsoft.com...
    > Is [XCPO] text? if so use
    > stLinkCriteria = "[XCPO]= '" &
    > Forms![frmLookup]![frmLookupsubform].Form![txtXCPO] &"'"
    >
    > "SAC" wrote:
    >
    > > I changed it to this and still get the same error:
    > >
    > > Thanks for your help.
    > >
    > > I changed it to this and still get the same error:
    > >
    > > stDocName = "frmTWDHPH"
    > >
    > > stLinkCriteria = "[XCPO]=" & Forms![frmLookup]![frmLookup
    > > subform].Form![txtXCPO]
    > >
    > > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > >
    > > "schasteen" <schasteen@discussions.microsoft.com> wrote in message
    > > news:30706918-0CAF-4028-91B6-003C72DBCE7D@microsoft.com...
    > > > Looks like you are trying to use a field from a subform, in which case

    > > your
    > > > criteria should be
    > > > stLinkCriteria = "[PHORD]=" &
    > > > Forms![frmLookup]![frmLookupsubform].form![TXTXTPO]
    > > >
    > > >
    > > > "SAC" wrote:
    > > >
    > > > > I'm trying to click a button on a form and open another form. Based

    on
    > > the
    > > > > criteria, the 2nd form should show 1 of 2 records.
    > > > >
    > > > > Right now I have:
    > > > >
    > > > > Dim stDocName As String
    > > > > Dim stLinkCriteria As String
    > > > >
    > > > > stDocName = "frmTWDHPH"
    > > > >
    > > > > stLinkCriteria = "[PHORD]=" & Forms![frmLookup]![frmLookup
    > > > > subform]![TXTXTPO]
    > > > >
    > > > > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > > > >
    > > > > This should show 2 records, but when I run this I get the error:

    "The
    > > > > OpenForm action was cancelled."
    > > > >
    > > > > What can I do to get this to run?
    > > > >
    > > > > Thanks.
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >
     
  7. SAC

    SAC
    Expand Collapse
    Guest

    Excellent! Thanks!
    "schasteen" <schasteen@discussions.microsoft.com> wrote in message
    news:45C1F73E-AD08-48E8-A86D-53BE970C0724@microsoft.com...
    > Is [XCPO] text? if so use
    > stLinkCriteria = "[XCPO]= '" &
    > Forms![frmLookup]![frmLookupsubform].Form![txtXCPO] &"'"
    >
    > "SAC" wrote:
    >
    > > I changed it to this and still get the same error:
    > >
    > > Thanks for your help.
    > >
    > > I changed it to this and still get the same error:
    > >
    > > stDocName = "frmTWDHPH"
    > >
    > > stLinkCriteria = "[XCPO]=" & Forms![frmLookup]![frmLookup
    > > subform].Form![txtXCPO]
    > >
    > > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > >
    > > "schasteen" <schasteen@discussions.microsoft.com> wrote in message
    > > news:30706918-0CAF-4028-91B6-003C72DBCE7D@microsoft.com...
    > > > Looks like you are trying to use a field from a subform, in which case

    > > your
    > > > criteria should be
    > > > stLinkCriteria = "[PHORD]=" &
    > > > Forms![frmLookup]![frmLookupsubform].form![TXTXTPO]
    > > >
    > > >
    > > > "SAC" wrote:
    > > >
    > > > > I'm trying to click a button on a form and open another form. Based

    on
    > > the
    > > > > criteria, the 2nd form should show 1 of 2 records.
    > > > >
    > > > > Right now I have:
    > > > >
    > > > > Dim stDocName As String
    > > > > Dim stLinkCriteria As String
    > > > >
    > > > > stDocName = "frmTWDHPH"
    > > > >
    > > > > stLinkCriteria = "[PHORD]=" & Forms![frmLookup]![frmLookup
    > > > > subform]![TXTXTPO]
    > > > >
    > > > > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > > > >
    > > > > This should show 2 records, but when I run this I get the error:

    "The
    > > > > OpenForm action was cancelled."
    > > > >
    > > > > What can I do to get this to run?
    > > > >
    > > > > Thanks.
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >
     
  8. SAC

    SAC
    Expand Collapse
    Guest

    Got it! Thanks!
    "schasteen" <schasteen@discussions.microsoft.com> wrote in message
    news:45C1F73E-AD08-48E8-A86D-53BE970C0724@microsoft.com...
    > Is [XCPO] text? if so use
    > stLinkCriteria = "[XCPO]= '" &
    > Forms![frmLookup]![frmLookupsubform].Form![txtXCPO] &"'"
    >
    > "SAC" wrote:
    >
    > > I changed it to this and still get the same error:
    > >
    > > Thanks for your help.
    > >
    > > I changed it to this and still get the same error:
    > >
    > > stDocName = "frmTWDHPH"
    > >
    > > stLinkCriteria = "[XCPO]=" & Forms![frmLookup]![frmLookup
    > > subform].Form![txtXCPO]
    > >
    > > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > >
    > > "schasteen" <schasteen@discussions.microsoft.com> wrote in message
    > > news:30706918-0CAF-4028-91B6-003C72DBCE7D@microsoft.com...
    > > > Looks like you are trying to use a field from a subform, in which case

    > > your
    > > > criteria should be
    > > > stLinkCriteria = "[PHORD]=" &
    > > > Forms![frmLookup]![frmLookupsubform].form![TXTXTPO]
    > > >
    > > >
    > > > "SAC" wrote:
    > > >
    > > > > I'm trying to click a button on a form and open another form. Based

    on
    > > the
    > > > > criteria, the 2nd form should show 1 of 2 records.
    > > > >
    > > > > Right now I have:
    > > > >
    > > > > Dim stDocName As String
    > > > > Dim stLinkCriteria As String
    > > > >
    > > > > stDocName = "frmTWDHPH"
    > > > >
    > > > > stLinkCriteria = "[PHORD]=" & Forms![frmLookup]![frmLookup
    > > > > subform]![TXTXTPO]
    > > > >
    > > > > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > > > >
    > > > > This should show 2 records, but when I run this I get the error:

    "The
    > > > > OpenForm action was cancelled."
    > > > >
    > > > > What can I do to get this to run?
    > > > >
    > > > > Thanks.
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >
     

Share This Page