Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find a record using a macro

Status
Not open for further replies.

lucybelle

MIS
Apr 9, 2001
58
US
I converted an Access 97 database to Access 2003 and have a problem with a macro running properly.

The find and Replace dialog box is not closing after the macro runs. After the record is found, I get the message that says the record was not found, as if it would if you clicked on Find Next.

To find a client, the following event procedure is on the control, CaseName:

Private Sub Case_Name_DblClick(Cancel As Integer)

DoCmd.OpenForm "frmcpsmasterfind"

End Sub

I select the client from the list and click the control, Search, that runs the following macro:

Action Action Argument

GoToControl Control Name - CaseName
SendKeys Keystrokes - ^c
Wait - Yes
Close Save – Prompt
GoToRecord Record – First
GoToContol Control Name – CaseName
SendKeys Keystrokes - ^v{ENTER}{TAB 8}{ENTER}
Wait – No
RunCommand Command – Find

I hope someone can help me solve this problem. Thanks.
 
why not replace the macro with VBA code?

something like

me.recordsetclone.find "MyKey = " & Me.key
if me.rcordsetclone.nomatch then
' code to display message in here
else
me.bookmark = me.recordsetclone.bookmark
end if

where MyKey is the filed name of you key field and key is the control name where you have entered the search key

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
I tried using the VBA code and got this message: "Run-time error 438. Object doesn't support this property or method."

I changed keyname to the field name and key to the control name. I don't know how to write code, so I'm limited to what I can do. Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top