Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004

    Unanswered: Selecting a value

    I am having a problem with a form's coding. I have a table with 3 fields -name, boxno, missing(true/false). On my form the user select a client form a combo box of their names. This affects the boxno listbox which contains all boxes 1/more for that client. A query is run when the user clicks on a value in the listbox, however I want it so if the listbox only contains 1 entry, the user does not have to click on the box to find out if it is missing.
    Here is my code:
    Dim rs As Object
    Set rs = Me.Recordset.Clone
    rs.findfirst "[name]='" & Me![Combo1] & "'"
    Me.Bookmark = rs.Bookmark
    Me.lst.RowSource = "SELECT dead.[box] FROM dead WHERE (((dead.[name])=[Forms]![Dead]![Combo1]));"
    Me.lst.Visible = True

    If I add the query coding (from the on click procedure of the listbox) below this, the following error message appears: "the value you entered isn't valid for this field". Below is the query code:

    Me.true = DLookup("[Query1].[missing]", "[query1]")
    If Me.true = False Then
    Me.Missing_Box.Visible = False
    GoTo fin
    Me.Missing_Box.Visible = True
    Me.Missing_Box = "MISSING"
    End If
    Exit Sub

    Can somebody please help?

  2. #2
    Join Date
    Oct 2003
    I can't picture the problem. Could you please supply some sample data and/or a picture of the form?

    The GoTo fin line is useless
    Whar are me.true and me.missing_box? Are their data types boolean/yes/no and text respectively?
    is dead just a bogus name for putting your problem to the internet, or is your table called dead for some reason?

    If Me.lst.RowSource already has
    "SELECT dead.[box] FROM dead WHERE (((dead.[name])=[Forms]![Dead]![Combo1]));"
    then you should only have to do lst.requery

Posting Permissions

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