Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    hitesh_asrani_j is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    75

    Unhappy Search Criteria Error

    Hello Guys,

    I am new to Access Forum, and also new to MS ACCESS.



    Recently i created a DB and allowed Access to create the Primary Key (i.e., ID) and also created a Form with certain feilds.
    I created a button with an option to search using once of the feilds from the form.
    But put fill the feild for and click on the button, the result is displayed but also that search is feeded in the Database any option to stop this :'(

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Quote Originally Posted by hitesh_asrani_j View Post
    But put fill the feild for and click on the button, the result is displayed but also that search is feeded in the Database any option to stop this :'(
    It is difficult to understand what you are saying here.
    Can you explain in different words?

  3. #3
    hitesh_asrani_j is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    75
    Recently i created a DB and allowed Access to create the Primary Key (i.e., ID) and also created a Form with certain fields.
    I created a button with an option to search using one of the fields from the form.
    I fill the field for searching and click on the button, the result is displayed but also that search is feeded in the Database any option to stop this :'(

    apologies, i was actually in the office son couldn type properly...

    i can attach the files ?? watsay??

  4. #4
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Sure - attach the DB & I'll look at it.

  5. #5
    hitesh_asrani_j is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    75
    Pplease find the dB attached.

  6. #6
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    What do you mean when you say, 'that search is feeded in the database'?

  7. #7
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Hi Hitesh,
    I opened up your DB and ran the Form named 'Copy of 12-09-2011'.

    This is the code behind the Search button:

    Code:
     
    Private Sub Command229_Click()
    Dim strCriteria As String
    Dim ReportDate As Date
     
    ReportDate = Me.[Report Date]
    strCriteria = "[Agent] = '" & Me.[Agent] & "' "
    strCriteria = strCriteria & "AND [Report Date] = #" & [Report Date] - 1 & "#"
    DoCmd.OpenForm "DetailForm", acFormDS, , strCriteria
     
    End Sub
    It is doing exactly what it is supposed to be doing.

    It is displaying ALL records in the DetailForm that have a matching Agent and a date that is one day before the [Report Date] on the 'Copy of 12-09-2011' form.

    I modified some dates in your table.
    For agent 'Finance' - I changed the first three 'Report Date' values to 9/13/2011.

    Then I opened the Form and with the Form on the first Record [Customer Name Colm] AND Report Date 9/13/2011 - I clicked the Search button.

    I got 8 rows of data - all with Agent 'Finance' and Report Date 9/12/2011 - shown in Datasheet view - on DetailForm.

    If you want to see only ONE record at a time on the DetailForm - change this:

    Code:
    DoCmd.OpenForm "DetailForm", acFormDS, , strCriteria
    to

    Code:
    DoCmd.OpenForm "DetailForm", , , strCriteria
    Let me know if I am not understanding your problem.
    Last edited by Robeen; 09-22-2011 at 09:15 AM. Reason: Missing info.

  8. #8
    hitesh_asrani_j is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    75
    Yes, I know that the command is working properly but the problem is every time u put some date and agent name for searching you get the correct result and after that if i have to save a new record i click on "add record" and even that search criteria is saved :|

  9. #9
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    I just did a Search. It worked fine.

    Then I clicked Add Record and put some test data in and clicked Save Record. And the record was saved - just like it was supposed to be.

    I think I still don't understand the error you are talking about.


  10. #10
    hitesh_asrani_j is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    75
    All the buttons are working fine checked and tested but when you will see the data you will find that, the search criteria you used also was saved taking a new ID

  11. #11
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    I just did what you said.

    After completing the Search, I closed the DetailForm & created a new record.

    The new record I created was given a new ID [Auto Number].

    The record I was on when I clicked the Search button - remained unchanged. It was not given a new ID.
    Last edited by Robeen; 09-22-2011 at 01:02 PM. Reason: Typo.

  12. #12
    hitesh_asrani_j is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    75
    As soon as u change the date or change the agent name a new ID is generated, right?

  13. #13
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Hi Hitesh,

    I think you should post your question again in a new thread.

    I am finding it very diffucult to understand the problem the way you are wording it and I don't want to delay you any further.

    I know there are some very expert users on this site & I hope they can understand what you are saying better than I have been able to.

    All the best.

  14. #14
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    I just changed the Agent on the first record - ID 1 and now the new agent name is in the table - and the ID in the table is still 1.

    Then - I changed the Report Date on the first record - and clicked 'Save' and now the new Report Date is in the table - and the ID in the table is still 1.

    So - I am still not sure what you mean.

    Sorry I don't seem to understand what you mean.


  15. #15
    hitesh_asrani_j is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    75
    !!!!! !!!!! Sad

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Complex Search Criteria
    By dutrac6835 in forum Queries
    Replies: 8
    Last Post: 06-23-2011, 04:11 PM
  2. Search Criteria
    By Meccer in forum Forms
    Replies: 1
    Last Post: 04-01-2011, 12:53 PM
  3. Search By Criteria - Flexible Criteria Fields
    By lilanngel in forum Access
    Replies: 0
    Last Post: 03-16-2011, 06:25 PM
  4. Search with multiple criteria
    By injanib in forum Forms
    Replies: 1
    Last Post: 01-16-2011, 11:51 PM
  5. search criteria in a form fails!
    By maxbre in forum Programming
    Replies: 2
    Last Post: 12-01-2010, 06:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums