Results 1 to 7 of 7
  1. #1
    Lounger
    Join Date
    Sep 2002
    Location
    Camp Lejeune, North Carolina
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    OpenForm where condition (a2k)

    I'm trying to open a form that brings up all the records with (example: "1") as an entry. I have a search form where the user selects which field they want to search in, and then types or selects what they want to search for. When I try this, it brings up all the records with a 1 in it (i.e. 1, 10, 18). The column(SearchIn) and the data(SearchFor) are variables. Here's what I've got:

    docmd.OpenForm "frmSearchResults", acNormal,, "["+SearchIn+"]" = SearchFor

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

    Re: OpenForm where condition (a2k)

    This is remarkably like the questions you asked in the thread starting at <post#=364191>post 364191</post#>. The way you state the where-condition is wrong. It should be a string, not an expression. Moreover, the where-condition should look different depending on whether the field selected by the user is a text or memo field, a numeric field or a date/time field. If you want to handle all that in code, it will become more complicated (than I would recommend trying now.)

    For numeric fields, it should look like this:

    DoCmd.OpenForm "frmSearchResults", acNormal, , "[" & SearchIn & "] = " & SearchFor

    Note that the = symbol has been moved inside the quotes.

  3. #3
    Lounger
    Join Date
    Sep 2002
    Location
    Camp Lejeune, North Carolina
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: OpenForm where condition (a2k)

    i tried your way, but entering "1" still returns "10, 11, etc"...btw, thanks for all your help Hans

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

    Re: OpenForm where condition (a2k)

    What kind of field (text, number, ...) are you testing this on?

  5. #5
    Lounger
    Join Date
    Sep 2002
    Location
    Camp Lejeune, North Carolina
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: OpenForm where condition (a2k)

    Its a number field

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

    Re: OpenForm where condition (a2k)

    I don't think we can solve this without seeing the database. Could you post a stripped-down copy of your database?
    <UL><LI>Make a copy of the database and work with that.
    <LI>Remove all database objects (tables, queries, forms, reports, macros and modules) that are not relevant to the problem.
    <LI>In the remaining table(s), remove most records - leave only the minimum number necessary to demonstrate the problem.
    <LI>Remove or modify data of a confidential nature.
    <LI>Do a compact and repair (Tools/Database Utilities).
    <LI>Make a zip file containing the database; it should be below 100KB.
    <LI>If you have difficulties getting the zip file below 100 KB, save the database in Access 97 format and then zip it.
    <LI>Attach the zip file to a reply.[/list]That will enable Loungers to look at the problem directly.

  7. #7
    Lounger
    Join Date
    Sep 2002
    Location
    Camp Lejeune, North Carolina
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: OpenForm where condition (a2k)

    Well, after trying to get the db down to 100KB, I somehow got the code working...so I'll play around with it some more

Posting Permissions

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