473,387 Members | 1,844 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,387 software developers and data experts.

Supress error message on FindRecord command

I'm using the "DoCmd.FindRecord" method and it's working fine. But if there aren't any records to be found at all, I get a: "You can't use Find or Replace now" error message. How do I stop that error message from appearing?
Thank you,
Amy
Oct 31 '06 #1
6 5368
NeoPa
32,556 Expert Mod 16PB
I'm using the "DoCmd.FindRecord" method and it's working fine. But if there aren't any records to be found at all, I get a: "You can't use Find or Replace now" error message. How do I stop that error message from appearing?
Thank you,
Amy
Expand|Select|Wrap|Line Numbers
  1. On Error Resume Next
  2. DoCmd.FindRecord ...
  3. If Err > 0 Then {failed}
  4. On Error GoTo 0
Oct 31 '06 #2
That worked perfect! Thanks!!

Expand|Select|Wrap|Line Numbers
  1. On Error Resume Next
  2. DoCmd.FindRecord ...
  3. If Err > 0 Then {failed}
  4. On Error GoTo 0
Oct 31 '06 #3
neo1ra
4
Hi,

I'm trying to put the code:
Expand|Select|Wrap|Line Numbers
  1. On Error Resume Next
  2. DoCmd.FindRecord ...
  3. If Err > 0 Then {failed}
  4. On Error GoTo 0
  5.  
in this code
Expand|Select|Wrap|Line Numbers
  1. Dim studentRef As String
  2.     Dim search As String
  3. 'variables a usarse para guardarar los valores
  4. 'verifica si el campo text_barcode esta vacio
  5.     If IsNull(Me![text_BuscarEst]) Or (Me![text_BuscarEst]) = "" Then
  6.         MsgBox "¡Por favor ingrese un valor!", vbOKOnly, "Búsqueda inválida"
  7.         Me![text_BuscarEst].SetFocus
  8.     Exit Sub
  9. End If   
  10.     DoCmd.ShowAllRecords
  11.     DoCmd.GoToControl ("ID")
  12.     DoCmd.FindRecord Me!text_BuscarEst
  13.  
  14.     ID.SetFocus
  15.     studentRef = ID.Text
  16.     text_BuscarEst.SetFocus
  17.     search = text_BuscarEst.Text
  18.  
  19.     If studentRef = text_BuscarEst Then
  20.         MsgBox "Se encontró el #estudiante " & text_BuscarEst, vbOKOnly, "¡Felicidades!"
  21.         ID.SetFocus
  22.         txtSearch = ""
  23.       Else
  24.             MsgBox "Match Not Found For: " & text_BuscarEst & " - Please Try Again.", _
  25.             , "Invalid Search Criterion!"
  26.             text_BuscarEst.SetFocus
  27.  
  28.  
  29.     End If
The problem is that I don't know in wich part I have to put the code of the routine error to prevent the "You can't use find or replace now" error message.
Jan 30 '07 #4
NeoPa
32,556 Expert Mod 16PB
Try this version :
Expand|Select|Wrap|Line Numbers
  1. Dim studentRef As String
  2.     Dim search As String
  3. 'variables a usarse para guardarar los valores
  4. 'verifica si el campo text_barcode esta vacio
  5.     If IsNull(Me![text_BuscarEst]) Or (Me![text_BuscarEst]) = "" Then
  6.         MsgBox "¡Por favor ingrese un valor!", vbOKOnly, "Búsqueda inválida"
  7.         Me![text_BuscarEst].SetFocus
  8.     Exit Sub
  9. End If   
  10.     DoCmd.ShowAllRecords
  11.     DoCmd.GoToControl ("ID")
  12.     On Error Resume Next
  13.     DoCmd.FindRecord Me!text_BuscarEst
  14.     'You need to update this (following) line
  15.     If Err > 0 Then {failed}
  16.     On Error GoTo 0
  17.  
  18.     ID.SetFocus
  19.     studentRef = ID.Text
  20.     text_BuscarEst.SetFocus
  21.     search = text_BuscarEst.Text
  22.  
  23.     If studentRef = text_BuscarEst Then
  24.         MsgBox "Se encontró el #estudiante " & text_BuscarEst, vbOKOnly, "¡Felicidades!"
  25.         ID.SetFocus
  26.         txtSearch = ""
  27.       Else
  28.             MsgBox "Match Not Found For: " & text_BuscarEst & " - Please Try Again.", _
  29.             , "Invalid Search Criterion!"
  30.             text_BuscarEst.SetFocus
  31.  
  32.  
  33.     End If
Remember to update the line in bold.
Jan 30 '07 #5
neo1ra
4
Thank for your help the code work very good. I have a question, you don't wich book is a good starting in MS access with code examples.

Rafael
Feb 1 '07 #6
NeoPa
32,556 Expert Mod 16PB
Although I don't have a lot of personal experience of such things, I believe Access For Dummies and other titles in the series are supposed to be quite good.
Feb 1 '07 #7

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

Similar topics

8
by: Steve | last post by:
I have several pairs of synchronized subforms in an application. I have a Delete button for each pair that uses the following code or similar to delete a record in the second subform: ...
4
by: Mr. T | last post by:
Hi, I need some help here. I have a On Exit procedure on that opens a form. Whenever anyone clicks anything outside of it the form opens. No problem here. But I need it not to open if the...
2
by: jaishu | last post by:
Hi, I am getting this error "The command or action 'Show all records' isn't available now", i get this when i try to do DoCmd.ShowAllRecords DoCmd.GoToControl ("ID") DoCmd.FindRecord...
6
by: redashley40 | last post by:
This is my first attempt in SQL and PreparedStatement I have add the PreparedStatement and I'm not to sure if I'm doing it correctly. When I do a test run on Choose 1 ,or 2 I get this error. Error...
4
by: =?Utf-8?B?WUlndWNoaQ==?= | last post by:
Hi , I want to run a batch file from the c# code. Every time i run the batch file command prompt is displayed. I do not want to show this command prompt. Is there any way to suppress the...
7
by: BUmed | last post by:
Well, in need to find a record using a command button so I set up a FindRecord in a macro. Now the person wants to be able to find all the records that meet the last name criterian so I thought I...
4
by: RAG2007 | last post by:
Hi Having some problems with docmd.findrecord, getting runtime error 2162, in an adp, sql server back end. On my main form, I have a continuous view subform giving a list of subrecords within...
8
by: internetintern | last post by:
hello, I have a code like: Private sub button1_Click() DoCmd.FindRecord Me.fieldname.Value, acStart, , acSearchAll, , , False end sub but the problem is that the command stops searching at...
1
by: resqtech | last post by:
I am having an issue with an Access Database that worked at one time and after a Windows Update that screwed up the profile it stopped working. The following is what VB is stating causes the error. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.