How do I pass a parameter to an unbound form?

Discussion in 'Access Forms Coding' started by AkAlan via AccessMonster.com, Nov 5, 2008.

  1. I have a form with 3 continuous subforms that each have textboxes. Sometimes
    they have more data than can be shown without making the textbox relly large.
    I want to have the user doubleclick the text box to open another form with a
    really large textbox and dynamically supply the recordsource and criteria. I
    will post the event code that I am trying to make work. All I get is a blank
    form. Any help would be great.

    Dim stDocName As String
    Dim stLinkCriteria As String
    If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord

    Form_frmCarTextPopUp.RecordSource = "q_QcCarDiscrepancy"
    Form_frmCarTextPopUp.txtExpanded.ControlSource = "Discrepancy"
    stDocName = "frmCarTextPopUp"
    stLinkCriteria = "[CarInspNum]=" & "'" & Me![txtCarNum] & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly

    --
    Message posted via AccessMonster.com
    http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200811/1
     
    AkAlan via AccessMonster.com, Nov 5, 2008
    #1
    1. Advertising

  2. AkAlan via AccessMonster.com

    Beetle Guest

    I don't believe you can assign the recordsource, or the control source
    of any of the controls, until after the form is opened. That also means
    you won't be able to apply any criteria until afterwards either. You might
    try something like;


    DoCmd.OpenForm "frmCarTextPopUp", , , , acFormReadOnly

    With Forms!frmCarTextPopUp
    .RecordSource = "q_QcCarDiscrepancy"
    .Controls("txtExpanded").ControlSource = "Discrepancy"
    .Filter = "[CarInspNum]=""" & Me![txtCarNum] & """"
    .FiltetOn = True
    End With


    --
    _________

    Sean Bailey


    "AkAlan via AccessMonster.com" wrote:

    > I have a form with 3 continuous subforms that each have textboxes. Sometimes
    > they have more data than can be shown without making the textbox relly large.
    > I want to have the user doubleclick the text box to open another form with a
    > really large textbox and dynamically supply the recordsource and criteria. I
    > will post the event code that I am trying to make work. All I get is a blank
    > form. Any help would be great.
    >
    > Dim stDocName As String
    > Dim stLinkCriteria As String
    > If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord
    >
    > Form_frmCarTextPopUp.RecordSource = "q_QcCarDiscrepancy"
    > Form_frmCarTextPopUp.txtExpanded.ControlSource = "Discrepancy"
    > stDocName = "frmCarTextPopUp"
    > stLinkCriteria = "[CarInspNum]=" & "'" & Me![txtCarNum] & "'"
    > DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly
    >
    > --
    > Message posted via AccessMonster.com
    > http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200811/1
    >
    >
     
    Beetle, Nov 6, 2008
    #2
    1. Advertising

  3. I tried it but it opened a different record and errored on the .filteron =
    true.

    Beetle wrote:
    >I don't believe you can assign the recordsource, or the control source
    >of any of the controls, until after the form is opened. That also means
    >you won't be able to apply any criteria until afterwards either. You might
    >try something like;
    >
    > DoCmd.OpenForm "frmCarTextPopUp", , , , acFormReadOnly
    >
    > With Forms!frmCarTextPopUp
    > .RecordSource = "q_QcCarDiscrepancy"
    > .Controls("txtExpanded").ControlSource = "Discrepancy"
    > .Filter = "[CarInspNum]=""" & Me![txtCarNum] & """"
    > .FiltetOn = True
    > End With
    >
    >> I have a form with 3 continuous subforms that each have textboxes. Sometimes
    >> they have more data than can be shown without making the textbox relly large.

    >[quoted text clipped - 12 lines]
    >> stLinkCriteria = "[CarInspNum]=" & "'" & Me![txtCarNum] & "'"
    >> DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly


    --
    Message posted via AccessMonster.com
    http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200811/1
     
    AkAlan via AccessMonster.com, Nov 6, 2008
    #3
  4. I'm not sure it matters but I am using an ADP

    Beetle wrote:
    >I don't believe you can assign the recordsource, or the control source
    >of any of the controls, until after the form is opened. That also means
    >you won't be able to apply any criteria until afterwards either. You might
    >try something like;
    >
    > DoCmd.OpenForm "frmCarTextPopUp", , , , acFormReadOnly
    >
    > With Forms!frmCarTextPopUp
    > .RecordSource = "q_QcCarDiscrepancy"
    > .Controls("txtExpanded").ControlSource = "Discrepancy"
    > .Filter = "[CarInspNum]=""" & Me![txtCarNum] & """"
    > .FiltetOn = True
    > End With
    >
    >> I have a form with 3 continuous subforms that each have textboxes. Sometimes
    >> they have more data than can be shown without making the textbox relly large.

    >[quoted text clipped - 12 lines]
    >> stLinkCriteria = "[CarInspNum]=" & "'" & Me![txtCarNum] & "'"
    >> DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly


    --
    Message posted via http://www.accessmonster.com
     
    AkAlan via AccessMonster.com, Nov 6, 2008
    #4
  5. AkAlan via AccessMonster.com

    Dennis Guest

    I usually just code that in VBA, using ADO lookup methodology. Works like a
    charm.

    "AkAlan via AccessMonster.com" wrote:

    > I have a form with 3 continuous subforms that each have textboxes. Sometimes
    > they have more data than can be shown without making the textbox relly large.
    > I want to have the user doubleclick the text box to open another form with a
    > really large textbox and dynamically supply the recordsource and criteria. I
    > will post the event code that I am trying to make work. All I get is a blank
    > form. Any help would be great.
    >
    > Dim stDocName As String
    > Dim stLinkCriteria As String
    > If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord
    >
    > Form_frmCarTextPopUp.RecordSource = "q_QcCarDiscrepancy"
    > Form_frmCarTextPopUp.txtExpanded.ControlSource = "Discrepancy"
    > stDocName = "frmCarTextPopUp"
    > stLinkCriteria = "[CarInspNum]=" & "'" & Me![txtCarNum] & "'"
    > DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly
    >
    > --
    > Message posted via AccessMonster.com
    > http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200811/1
    >
    >
     
    Dennis, Nov 6, 2008
    #5
  6. Do you have an example? Thanks.

    Dennis wrote:
    >I usually just code that in VBA, using ADO lookup methodology. Works like a
    >charm.
    >
    >> I have a form with 3 continuous subforms that each have textboxes. Sometimes
    >> they have more data than can be shown without making the textbox relly large.

    >[quoted text clipped - 12 lines]
    >> stLinkCriteria = "[CarInspNum]=" & "'" & Me![txtCarNum] & "'"
    >> DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly


    --
    Message posted via http://www.accessmonster.com
     
    AkAlan via AccessMonster.com, Nov 6, 2008
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gérard Marcillac

    Unbound Form controls Unbound Form

    Gérard Marcillac, Jun 28, 2004, in forum: Access Forms
    Replies:
    0
    Views:
    86
    Gérard Marcillac
    Jun 28, 2004
  2. AFSSkier
    Replies:
    7
    Views:
    79
    Steve Schapel
    Sep 24, 2008
  3. JD McLeod

    Pass Data from Unbound Form to Bound Form

    JD McLeod, Jun 15, 2009, in forum: Access Forms
    Replies:
    2
    Views:
    52
    Dirk Goldgar
    Jun 16, 2009
  4. robert35
    Replies:
    1
    Views:
    149
    Guest
    Dec 15, 2004
  5. SAC
    Replies:
    7
    Views:
    107
Loading...

Share This Page