By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,225 Members | 1,430 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,225 IT Pros & Developers. It's quick & easy.

Need message for fields that are returned with no value!

P: 36

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.
Aug 12 '09 #1
Share this Question
Share on Google+
8 Replies

Expert 100+
P: 1,287
When you say "input" that StockID, how are you doing it? Possibly a combo box in the form header?
Aug 12 '09 #2

P: 36
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 :-)
Aug 12 '09 #3

Expert 100+
P: 1,287
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.
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSearchButton_Click()
  2. Dim intMatches As Integer
  3. Dim strWhereCondition As String
  4.     intMatches = DCount("StockID", "myQuery", "[StockID] = " & txtStockID)
  5.     If intMatches > 0 Then
  6.         strWhereCondition = "[StockID] = " & txtStockID
  7.         DoCmd.OpenForm "frmViewRecords", , , strWhereCondition
  8.     Else
  9.         MsgBox "No records found with that Stock ID Number"
  10.     End If
  11. End Sub
Aug 12 '09 #4

Expert 100+
P: 1,287
This is a lot like making your own prompt to enter parameters, because the built in one is pretty inflexible.
Aug 12 '09 #5

P: 36
Ok. Thanks again ChipR.
I will try it.
Thanks ever so much.
Aug 13 '09 #6

P: 36
Hey ChipR. Thanks ever so much, it worked Fantastic!
Aug 13 '09 #7

Expert 100+
P: 1,287
Glad to hear it. You're catching on quickly.
Aug 13 '09 #8

P: 36
Well that's because you're doing a gr8 job at explaining! Thanks.
Aug 13 '09 #9

Post your reply

Sign in to post your reply or Sign up for a free account.