Solved

Access 2007 FindRecord Macro does not work

Posted on 2015-02-08
7
37 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
  • 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Modern/Metro styled message box and input box that directly can replace MsgBox() and InputBox()in Microsoft Access 2013 and later. Also included is a preconfigured error box to be used in error handling.
This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now