Solved

Access 2007 FindRecord Macro does not work

Posted on 2015-02-08
7
41 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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.
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…

910 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

17 Experts available now in Live!

Get 1:1 Help Now