Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Sep 2002
    Location
    Indianapolis, Indiana, USA
    Posts
    80
    Thanks
    1
    Thanked 0 Times in 0 Posts

    listbox requery (97 sr2)

    I am using the tag property on an option control to get the default directory. I am displaying the directory in a listbox. When I requery, the listbox is cleared. What am I missing here in implementing the listbox?

    Private Sub Form_Open(Cancel As Integer)
    'lookup the default directory to use
    Option4.Value = -1
    Me!Option4.Tag = DLookup("[DefaultValue]", "DefaultValues", "[Reference] = 'DefaultDir'")
    MsgBox "Option4 tag is: " & Me!Option4.Tag
    Me!List16.Requery
    MsgBox "Option4 tag after requery is: " & Me!Option4.Tag
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: listbox requery (97 sr2)

    I don't understand the role of the Tag property of Option4. What is the relation with the list box? And what is the Row Source and Row Source Type of the list box?

  3. #3
    Star Lounger
    Join Date
    Sep 2002
    Location
    Indianapolis, Indiana, USA
    Posts
    80
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: listbox requery (97 sr2)

    I am using the option4.tag to hold the current directory. I want the user to be able to change the default directory and store a new default directory in a table that holds various defaults. I've attached a zip file of the test.db. Small but over the 100K when expanded.

    The row source is:

    SELECT DISTINCTROW qryDefault.DefaultValue FROM qryDefault WHERE (((qryDefault.Reference)=[forms]![Testopendialog].[option4].[tag]));

    I only threw in the requery because all of a sudden the listbox wouldn't display the directory. Since my original post, I was cleaning up the form and did a database compact and this seems to have cleared up the problem I was experiencing. So I removed the requery and it appears to work fine. But I still do not understand why the requery would clear the field. I have other code that executes a requery and it works as expected.
    Attached Files Attached Files

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: listbox requery (97 sr2)

    There is some confusion here. The query qryDefault expects that Option4.Tag corresponds to a value of the Reference field ("DefaultValue" in your example). The Form_Open code sets the value of Option4.Tag to the value of the DefaultValue field ("c:test" in your example). After this, qryDefault returns no records any more, for there are no records for which Reference = 'c:test'.

    (Frankly, I don't understand the rest of your code at all)

  5. #5
    Star Lounger
    Join Date
    Sep 2002
    Location
    Indianapolis, Indiana, USA
    Posts
    80
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: listbox requery (97 sr2)

    Can't see the trees because of the forest I think is the way it goes. Yup, doesn't help to feed the requery the result instead of the parameter. No wonder you and Access are confused.

    except for option6 the other code is nothing. Option 6 will toggle whether the user wants to change the default directory.

Posting Permissions

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