Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2004
    Location
    Texas
    Posts
    37

    Unanswered: Using returned value of a combobox ...

    OK, so my 1st example wasn't clear enough.
    I'll try again, here's a new example:

    Dim dbs As Database, tblSales As Recordset

    Set dbs = CurrentDb
    Set tblSales = dbs.OpenRecordset("sales")

    ' Sales table has 2 fields salesman1 & salesman2
    ' Sales table has 1 record and salesman1 & salesman2 is set to either True or False - It's a status holder

    ' In my form I have a combobox with the choice of either
    salesman1 or salesman2

    ' I want to be able to use the value from the combobox as the field pointer in the If statement but I can't seem to find the right syntax it either won't compile or I get error messages when process the form.

    tblSales.MoveFirst

    If tblSales!Me.Combobox = True Then
    Else
    End If


    __________________
    A2K - W2k
    Thanks & Regards
    Pete

  2. #2
    Join Date
    Oct 2001
    Location
    Chicago
    Posts
    440
    If tblSales!Combobox = True Then

  3. #3
    Join Date
    Jan 2004
    Location
    Texas
    Posts
    37
    Tried it ... got "Item not found in this collection" error msg.

    Anyother ideas?
    A2K - W2k
    Thanks & Regards
    Pete

  4. #4
    Join Date
    Oct 2001
    Location
    Chicago
    Posts
    440
    sorry
    Me!Combobox or Me.Combobox

  5. #5
    Join Date
    Jan 2004
    Location
    Texas
    Posts
    37
    Here's what I get with the following combinations:

    'where the contents of Me.combobox = "salesman2"
    ' ie If recSales!salesman2 = True Then yada yada


    If recSales!Me.combobox = True Then
    "Method or data member not found" when I debug>>compile

    If recSales!(Me.combobox) = True Then
    "Syntax error" when I debug>>compile

    If recSales!"Me.combobox" = True Then
    "Syntax error" when I debug>>compile

    If recSales![Me.combobox] = True Then
    Compiles but - "Item not found in this collection" when I DoCmd.Close

    If recSales!Me!combobox = True Then
    Compiles but - "Item not found in this collection" when I DoCmd.Close

    I'm starting to wonder if what I want to do is even possible.
    A2K - W2k
    Thanks & Regards
    Pete

  6. #6
    Join Date
    Jan 2004
    Location
    Texas
    Posts
    37
    my bad ... I meant tblSales in the previous example
    A2K - W2k
    Thanks & Regards
    Pete

  7. #7
    Join Date
    Jan 2004
    Location
    Texas
    Posts
    37
    Anyone?
    A2K - W2k
    Thanks & Regards
    Pete

  8. #8
    Join Date
    Oct 2001
    Location
    Chicago
    Posts
    440
    Sorry - I wasn't seeing what you were trying to do.

    try this-
    tblSales(Me!combobox)
    or
    tblSales(Me.combobox)

  9. #9
    Join Date
    Jan 2004
    Location
    Texas
    Posts
    37
    It works .... THANK YOU ... THANK YOU!!!!!!!!!!!!!!
    A2K - W2k
    Thanks & Regards
    Pete

Posting Permissions

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