Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2009
    Posts
    3

    Unhappy Unanswered: Open a new form when zero records are found

    i current am using a macro to conduct a search of 7 combo boxes through a query. at the moment when you select search, if there are no records found the results form comes up with no information on it. i want it to open a new form to say no records were found please refine your search. i have a text box on my results form which has a count formula in it so it counts the number of records found. i have been trying to use an if formula to open a new form when this count is zero but cannot manage to get it to work.

    the way in which i have tried to to put an action on the macro to runcode and used the expression builder to trype the code in. i dont know if this is correct being a bit of an access amateur.

    Any help would be most appreciated.

  2. #2
    Join Date
    Dec 2003
    Posts
    24
    Quote Originally Posted by cvsb7
    being a bit of an access amateur
    from a novice to amatuer
    When no matching records are found, it would be better if the ResultForm is not even opened!
    You could have the macro open the ResultForm only if 1 or more records found else display a message box warning the user, and stay put in the search form itself.

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    do youmean a new form or do you mean a message box

    msgbox("Please refine your search, no rows were found", vbinformation,"Searching for data"))
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Mar 2009
    Posts
    3
    could you please tell me how exactly i put that code into it. do i put that into an action on the macro and on the expression builder? im not familiar with writing code to perform actions.

    thanks

  5. #5
    Join Date
    Dec 2003
    Posts
    24
    place a code similar to this..
    Replace the recdCount with the variable which should be holding the records.
    code:
    If recdCount <= 0 Then
    MsgBox "No matching records found"
    Else
    'Your code to open the ResultForm
    End If

Posting Permissions

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