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

    --

     
    AkAlan via AccessMonster.com, Nov 5, 2008
    #1
    1. Advertisements

  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
    >
    > --

    >
    >
    >
     
    Beetle, Nov 6, 2008
    #2
    1. Advertisements

  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


    --

     
    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


    --
     
    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
    >
    > --

    >
    >
    >
     
    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


    --
     
    AkAlan via AccessMonster.com, Nov 6, 2008
    #6
    1. Advertisements

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. 1
    Replies:
    0
    Views:
    225
  2. Marcel K.
    Replies:
    2
    Views:
    103
  3. Tom \T\

    Combo Box on Unbound Form as Parameter for Query

    Tom \T\, Dec 12, 2003, in forum: Access Forms Coding
    Replies:
    1
    Views:
    113
    Ken Snell
    Dec 12, 2003
  4. Chris

    Unbound form/unbound control calculation

    Chris, Sep 30, 2005, in forum: Access Forms Coding
    Replies:
    2
    Views:
    227
    Chris
    Sep 30, 2005
  5. Kim Kautzmann

    Populate an Unbound Listbox based on an Unbound Combo box

    Kim Kautzmann, May 24, 2007, in forum: Access Forms Coding
    Replies:
    1
    Views:
    218
    KARL DEWEY
    May 24, 2007
  6. EVPLS
    Replies:
    1
    Views:
    219
    Arvin Meyer [MVP]
    Jan 19, 2008
  7. babyatx13 via AccessMonster.com

    pass a value to an unbound combo box in a different database.

    babyatx13 via AccessMonster.com, Jul 8, 2009, in forum: Access Forms Coding
    Replies:
    2
    Views:
    191
    babyatx13 via AccessMonster.com
    Jul 14, 2009
  8. VRakesh
    Replies:
    5
    Views:
    266
    Larry Linson
    Jan 22, 2010
Loading...