Need message for fields that are returned with no value!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • student2
    New Member
    • Aug 2009
    • 36

    Need message for fields that are returned with no value!

    Hi!

    I've designed a query.
    I've now created a form for the results of this query to be displayed.

    I'm able to view the results for what information is in the Db, however if I should input StockId as '1234' which is NOT in the current Database when I input that "1234" the field is returned Blank.

    e.g. [Enter StockId] I enter '1234' but since that is not a value in StockId the field is returned blank (form remains blank)

    I now wish to have a message advising the user that there is no such value in the database.

    I've tried using the MsgBox on the form's Error event but no such luck.

    Thanks again.
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    #2
    When you say "input" that StockID, how are you doing it? Possibly a combo box in the form header?

    Comment

    • student2
      New Member
      • Aug 2009
      • 36

      #3
      Oh Thanks again ChipR for always responding!

      When I refer to input, it's a query that I've used so it's the [Enter StockId] criteria that I refer to.

      e.g. A customer comes in and request a certain Stock....Let's say instead of StockId I use StockName as that criteria there......

      I desire to now have a message if I type "Charla" as the item requested and there is no such item.

      I'm not always clear.....but I hope you somewhat understand.

      Thanks again :-)

      Comment

      • ChipR
        Recognized Expert Top Contributor
        • Jul 2008
        • 1289

        #4
        Oh I see what you mean. You want to filter the query results on your form, right? Here's how I would do it. Create a form where the user can enter search criteria before you show the form with the records. For example, your form has a txtStockID where the user enters the number they want to search for. You can expand this code to check more than one box. Then just open a form that shows your whole recordset, but filter it using the criteria.
        Code:
        Private Sub cmdSearchButton_Click()
        Dim intMatches As Integer
        Dim strWhereCondition As String
            intMatches = DCount("StockID", "myQuery", "[StockID] = " & txtStockID)
            If intMatches > 0 Then
                strWhereCondition = "[StockID] = " & txtStockID
                DoCmd.OpenForm "frmViewRecords", , , strWhereCondition
            Else
                MsgBox "No records found with that Stock ID Number"
            End If
        End Sub

        Comment

        • ChipR
          Recognized Expert Top Contributor
          • Jul 2008
          • 1289

          #5
          This is a lot like making your own prompt to enter parameters, because the built in one is pretty inflexible.

          Comment

          • student2
            New Member
            • Aug 2009
            • 36

            #6
            Ok. Thanks again ChipR.
            I will try it.
            Thanks ever so much.

            Comment

            • student2
              New Member
              • Aug 2009
              • 36

              #7
              Hey ChipR. Thanks ever so much, it worked Fantastic!

              Comment

              • ChipR
                Recognized Expert Top Contributor
                • Jul 2008
                • 1289

                #8
                Glad to hear it. You're catching on quickly.

                Comment

                • student2
                  New Member
                  • Aug 2009
                  • 36

                  #9
                  Well that's because you're doing a gr8 job at explaining! Thanks.

                  Comment

                  Working...