Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2005
    Posts
    196

    Unanswered: Changing source object stops events from happening.

    I have the following line in my code on the exit event of a text box:

    Code:
    qryDisplayProducts2.SourceObject = "Query.QryDisplayProductsByCode"
    QryDisplayProducts2 is a sub form - within this sub form I have the following code on a text box:

    [code]Private Sub ART_KEY_DblClick(Cancel As Integer)
    MsgBox ART_KEY.Value
    MsgBox ART_NAME.Value
    End Sub[code]

    This works fine when you first enter the code. However, when you have executed the code which changes the source object of the form, it no longer executes the dblClick event on the sub form. I don't see why as you are changing the sourceobject rather than the form itself. Any ideas anyone? Cheers.

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    ??????

    motherForm has a subform control containing childForm

    childForm has a textbox that runs code in _dblclick()

    you have some code elsewhere that uses .sourceobject to replace childForm with anotherForm in the subform control.

    of course code in childForm is not going to run - childForm has gone away.

    are you sure you should be using .sourceobject ??

    what are you trying to achieve with .sourceobject ??

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Aug 2005
    Posts
    196
    Quote Originally Posted by izyrider
    ??????

    motherForm has a subform control containing childForm

    childForm has a textbox that runs code in _dblclick()

    you have some code elsewhere that uses .sourceobject to replace childForm with anotherForm in the subform control.

    of course code in childForm is not going to run - childForm has gone away.

    are you sure you should be using .sourceobject ??
    what are you trying to achieve with .sourceobject ??izy
    Many thanks for your reply.
    I have three different text boxes, for which the prupose is to search for records. On the exit event of each of these three text boxes, it takes the value and uses that in a query. As each search is different, I am using three different queries and exiting each of the text boxes changes the sourceobject to be the relevant query, cheers.

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    I am using three different queries and exiting each of the text boxes changes the sourceobject to be the relevant query
    .sourceobject is trying to replace the form-object that is sitting in your subform-control

    try:
    .rowsource if you are feeding a list
    .recordsource if you are feeding a form

    izy
    currently using SS 2008R2

  5. #5
    Join Date
    Aug 2005
    Posts
    196
    try:
    .rowsource if you are feeding a list
    .recordsource if you are feeding a form
    Neither are available to use - the only property it brings up on the list that will do the job is .sourceobject

    EDIT: It was there - when I added .Form! Many thanks for your help.
    Last edited by Fuerteventura; 12-12-05 at 12:47.

Posting Permissions

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