Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Access 2007 FindRecord Macro does not work

Posted on 2015-02-08
7
Medium Priority
?
114 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

916 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