Results 1 to 8 of 8
  1. #1
    seb is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2010
    Posts
    73

    Msgbox in a query with parameters


    Hello

    I have a form (FSearch) based in a parameter query. When user enter data in the unbound txtboxes another form (FData) displays the query, however, if there are no records, the FData shows nothing.
    I need to do the following:
    1.When user run the query and there are no records in the db I need a message in FData "Your search has no records". Where do I have to write the instruction?Then I need to go back to the FSearch.

    2. If records are found in the db, I need a txtbox saying in FData "Your search found xxx records".
    Could you tell me how to do this two options?

    Many thanks

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    I am attaching a small sample for you. Whe you open the db a start up form will open with a combobox and a list box.

    When you select a skill level in the combo box two things happen:
    1) A message box prompts how many records are there.
    2) The records are displayed in the list box.

    Code used:

    On the AfterUpdate Event of the Combo Box:

    Private Sub Combo10_AfterUpdate()
    Dim intCount As Integer

    intCount = IIf(IsNull(DCount("[ID]", "Sheet1", "[ID]=" & Me.Combo10)), 0, DCount("[ID]", "Sheet1", "[ID]=" & Me.Combo10))

    Select Case intCount
    Case Is = 0
    MsgBox "There are no Records"
    Case Is > 0
    MsgBox "There are " & intCount & " Records"
    End Select
    Me.List14.Requery
    End Sub

  3. #3
    seb is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2010
    Posts
    73
    Hi Maximus. Your sample works great. Thank you very much.
    One more thing. How can I use the close button at the right upper corner of the form to close the form and return to FSearch form?

    Thanks again

  4. #4
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    On the on close event you have to put

    Docmd.openForm

    put the form name

    so when you close the form the other one opens.

  5. #5
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    mark the thread solved.

  6. #6
    seb is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2010
    Posts
    73
    Maximuss.
    Excellent. Now I have what user needs.
    Many thanks again

  7. #7
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    please mark this thread solved. this will help someone else with the same problem.

  8. #8
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Mark the thread solved. Please.........................................

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 07-01-2010, 07:55 PM
  2. Split a string for use as query parameters.
    By Hobbes29 in forum Forms
    Replies: 3
    Last Post: 06-27-2010, 04:39 PM
  3. Query NOT taking the two parameters WHY?
    By iamraja5 in forum Forms
    Replies: 7
    Last Post: 03-16-2010, 04:29 AM
  4. If Query result Is Null...MsgBox..Okl
    By Bruce in forum Forms
    Replies: 28
    Last Post: 03-10-2010, 10:57 AM
  5. Add query parameters in with vbCode?
    By ~SwAmPdOnKeY~ in forum Programming
    Replies: 0
    Last Post: 08-07-2008, 07:58 PM

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