Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Access 2007 FindRecord Macro does not work

Posted on 2015-02-08
7
Medium Priority
?
91 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
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.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

721 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