Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Jan 2002
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Update Event from a Combo Box (97)

    I've created a form to search another form - depending on a field named 'Organization'. I'm using an 'OnUpdate' event procedure where a combo box lists the possible organizations, the user chooses one, which should open up the form Contacts with a filter set to the combo box selection. I used the following procedure, but it doesn't recognize the text in the combo box, just the number. How can I make it work using the text to set the filter rather than the underlying number from the combo box. If anyone has a better way, I'm open to suggestions as well. Thanks.

    Private Sub Combo7_AfterUpdate()
    Dim stDocName As String
    Dim stLinkCriteria As String
    Dim stInput As String

    stDocName = "Contacts"
    stInput = "[Me![Combo7].Value]"

    stLinkCriteria = "[Organization]=" & "' " & [stInput] & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria


    Combo7 = " "

    Exit_Combo7_AfterUpdate:
    Exit Sub

    End Sub

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Update Event from a Combo Box (97)

    The expression me!combo7.value returns the value of the bound column in the current row. It would seem logical that this is an ID number of the organization. If you were going to open the other form and look for an organization you selected, you should be doing it by this ID#, name the org name.

    Also, you used this expression: stInput = "[Me![Combo7].Value]"
    This does not set stInput equal to the value of combo7, rather it set it equal to the string of characters "Me!combo7.value"! You should have just said: stInput = Me![Combo7].Value
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Lounger
    Join Date
    Jan 2002
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update Event from a Combo Box (97)

    I took the quotations out, but it still doesn't work. I thought about using the ID#, but the combo box comes from a list with repeating values which I've filtered out using the Distinct property. If I put in Enron and more than one person works there, all but the first record would be filtered out. I can get the search to work using a text box, I just can't figure out why it doesn't work with a text box. Any suggestions would be greatly appreciated.

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update Event from a Combo Box (97)

    You have to remove these brackets also:
    stLinkCriteria = "[Organization]=" & "' " & [stInput] & "'"
    to
    stLinkCriteria = "[Organization]=" & "' " & stInput & "'"
    Francois

  5. #5
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Update Event from a Combo Box (97)

    I'm having trouble understanding your situation. What is the bound column in your combo box? You said that it is returning a number. The number for what, the organization (like an org. ID)? Does your Contact table contain the organization by name or #?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  6. #6
    Lounger
    Join Date
    Jan 2002
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update Event from a Combo Box (97)

    I got it to work!!! One of my quotations had an extra space in it. Thanks for the help.

Posting Permissions

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