Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246

    Unanswered: Pass through of commands taken

    Hi,
    I have a form that has 2 main fields (field_A & field_B).
    The user can look at child data for either field_A or field_B by selecting one of 2 command buttons.
    Button_1 displays a further form that filters records showing data that only matches field_A.
    Button_2 displays a further form that filters records showing data that only matches field_B.

    What I want to know is can I pass through to the child form a flag to show which command button has been clicked on?

    Regards
    John

  2. #2
    Join Date
    Feb 2004
    Location
    CT,USA
    Posts
    250
    Yes, hide the flag as a control on the master form & make it invisible. Reference it as Form.Formname.txtboxname from the sub-forms.

  3. #3
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Hi,
    Thanks for the reply.

    I understand the referencing on the subform but I'm not quite sure that I understand how I log the click event on the master?
    Can you expand a bit please

    Regards
    John

  4. #4
    Join Date
    Feb 2004
    Location
    CT,USA
    Posts
    250
    Private Sub Button_1_Click()

    Form.Formname.txtboxFlagname = "1"
    end sub

    For button 2 click proc change to "2"


    then use it some thing like:

    select case Form.Formname.txtboxname
    case 1
    subform.caption = "Button 1 was pressed"
    case 2
    subform.caption = "Button 2 was pressed"
    end select

    HTH

  5. #5
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Hi
    Many thanks again for this, but I have a issue

    I've taken you code and added it in to the On Click code already assigned to each button. But I get an error. I've attached the code, the 2nd line is the error in question. (application defined or object defined error)

    Private Sub SECS_4_this_cn_Click()

    Form.Collection_note_SubForm.txtboxwhichutton = "1"

    On Error GoTo Err_SECS_4_this_cn_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Security_subform"

    stLinkCriteria = "[CollectNoteRef]=" & "'" & Me![CollectNoteRef] & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria


    Exit_SECS_4_this_cn_Click:
    Exit Sub

    Err_SECS_4_this_cn_Click:
    MsgBox Err.Description
    Resume Exit_SECS_4_this_cn_Click


    End Sub

    Thanks
    John

  6. #6
    Join Date
    Feb 2004
    Location
    CT,USA
    Posts
    250
    Sorry, I forgot to check the exact syntax. I modified order of commands, too. Try this:

    Private Sub SECS_4_this_cn_Click()
    On Error GoTo Err_SECS_4_this_cn_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    Forms!Collection_note_SubForm.txtboxwhichutton = "1"

    stDocName = "Security_subform"

    stLinkCriteria = "[CollectNoteRef]=" & "'" & Me![CollectNoteRef] & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria


    Exit_SECS_4_this_cn_Click:
    Exit Sub
    (error section here)
    Last edited by poliarci; 03-18-04 at 14:59.

  7. #7
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Thanks mate for your input,
    Unfortunately it still isn't working but fortunately its highlighted a real problem elsewhere that I need to sort out before I can sort this out.

    Thanks again
    John

  8. #8
    Join Date
    Jun 2003
    Location
    Belgium
    Posts
    133
    There's still a more interesting way to do the trick : OpenArgs.

    In the code where you open the form, add an argument with the buttons name or number :

    DoCmd.OpenForm "MyForm", , , stLinkCriteria, , ,"Button1"

    Then, when your MyForm is open, the name of the opening button is available in the property Me!OpenArgs

    Try it!

  9. #9
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Thanks Herman for the tip, I'll give it a try later on today.

    Regards
    John

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •