Solved

Access 2007 FindRecord Macro does not work

Posted on 2015-02-08
7
68 Views
Last Modified: 2016-05-22
I have a database of people and wish to go to a particular record. I have an unbound text box (FindLname) and a button that when I push it does the following...

1. Goes to the field LName
2. Goes to the last record
3. Then uses FindRecord to seach for a record that begins with the value in the text box (FindLname).

Currently only steps 1 and 2 work. Strangely, at one point, this macro did work.
Access-2007-2-8-15.jpg
0
Comment
Question by:Starbuck67
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40597339
Why does the macro need to go to the last record?
(Remove that section of the macro and see what happens)

All that is needed is to move to the matching record.

I don't see anything wrong with the Find record portion of the macro...
Are you sure you spelled the names properly?, Are you sure none of the objects were renamed?

JeffCoachman
0
 

Author Comment

by:Starbuck67
ID: 40597424
I deleted the go to last record portion. I suppose there must have been some reason for that, but I can't remember.

Unfortunately deletion of that line did not make a difference. The macro just takes me to the first record and sits there.

Instead of using the the location statement for "Find What" I just substituted some text. With the text, everything works fine. So, there must be something going on with the location statement, but I can't figure it out
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40597526
Oh,
Your "Match" argument is set to "Start of Field"...
Change it to: "Any Part Of Field"
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40597553
...because if you type your search wrong (bad spelling) the macro will just sit there, ...as you state.
Because there are no matches.

FWIW,  a very similar Macro works just fine for me...
See the attached sample db
Database65.mdb
0
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 40598598
Try using an unbound combobox instead, filled with the key field (usually in an invisible column) and the first and last name.  This is the boilerplate code for the AfterUpdate event of the combobox (use either the numeric or text line, depending on the key field):

Private Sub cboSelect_AfterUpdate()
'Created by Helen Feddema 29-Apr-2011
'Last modified by Helen Feddema 29-Apr-2011

On Error GoTo ErrorHandler

   Dim strSearch As String

   'For text IDs
   strSearch = "[______ID] = " & Chr$(39) & Me.ActiveControl.Value _
      & Chr$(39)

   'For numeric IDs
   strSearch = "[______ID] = " & Me.ActiveControl.Value

   'Find the record that matches the control
   Me.Recordset.FindFirst strSearch

ErrorHandlerExit:
   Exit Sub

ErrorHandler:
   MsgBox "Error No: " & Err.Number _
      & " in " & Me.ActiveControl.Name & " procedure; " _
      & "Description: " & Err.Description
   Resume ErrorHandlerExit

Open in new window

0
 

Accepted Solution

by:
Starbuck67 earned 0 total points
ID: 40599703
I think I have found what the problem is. I noticed at the top of the screen the statement "Security Warning  Certain content in the database has been disabled" with a button called 'Options' next to it. Pressing that button leads to another dialogue box the is called 'VBA Macro' with a choice to either provide 'protection against unknown content' or to 'enable this content.'

When I choose the enable content, then the macro we have been working on was just fine.
Access-2007-2-8-15---5.jpg
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a serious pitfall that can happen when deleting shapes using VBA.
Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question