473,326 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Access Search Box Error Handling

I'm relitively new to coding items in Access, so any detailed help anyone could provide would be greatly appreciated.

I have a form that has information from 2 seperate tables. I've created a search box to look up information in a field "PO_Number". I've tried two different methods, which both work well for actually finding the records. (I'll post the code below with both examples I've used) I want to add to the code so that if there is not a match, a msgbox will pop up saying so.

Right now when no information is found either the first or next record is selected (which is not a match to what is searched)

Thanks in advance for any assistance!

Private Sub Combo81_AfterUpdate()

' DoCmd.ShowAllRecords
' Me!PO_Number.SetFocus
' DoCmd.FindRecord Me!Combo81
' Combo81.Value = ""

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[PO_Number] = " & Str(Nz(Me![Combo81], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Combo81.Value = ""

End Sub
Jul 20 '07 #1
3 1626
JKing
1,206 Expert 1GB
Hi there! Conveniently there is a property for just this case and it's called NoMatch. It returns true when no match is found.

Expand|Select|Wrap|Line Numbers
  1. Set rs = Me.Recordset.Clone
  2. rs.FindFirst "[PO_Number] = " & Str(Nz(Me![Combo81], 0))
  3. If rs.NoMatch Then
  4. MsgBox "Sorry No Matches!"
  5. Else
  6. Me.Bookmark = rs.Bookmark
  7. Combo81.Value = ""
  8. End If.
  9.  
Jul 20 '07 #2
Works like a champ! Thanks much for the help!
Jul 23 '07 #3
JKing
1,206 Expert 1GB
You're very welcome.
Jul 23 '07 #4

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

Similar topics

1
by: annie | last post by:
Hi all, I have recently ported my Access 2000 app to SQL Server, keeping the Access client as the front end using linked tables. I am also using triggers on my SQL tables to trap orphan...
3
by: Sebastian C. | last post by:
Hello everybody Since I upgraded my Office XP Professional to SP3 I got strange behaviour. Pieces of code which works for 3 years now are suddenly stop to work properly. I have Office XP...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
16
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
0
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool including SourceOffSite, SourceAnyWhere and VSS Remoting This article makes a detailed...
3
by: Kaur | last post by:
Hi, I would appriceate any help to correct the code error that I am getting for the onclick event of a cmd button. I have two forms. Main Form "frmQuestion" and form 2 "SfrmQuestion"....
0
by: Lysander | last post by:
Thought I would give something back with a few articles. This article is a bit of code to add error handling. When I have time, I want to write articles on multilingual databases, and Access...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
9
by: ARC | last post by:
Hello all, I developed a tool a year or so ago for adding your own spell-checker to an access application. This is mainly for those using the runtime, as you can't distribute the spell-checker...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.