docmd.searchforrecord doesnt work

Jota

New member
Local time
Today, 19:47
Joined
Nov 20, 2011
Messages
3
Hi,
I have a command button in a continuos form header , that the code is simple:

docmd.searchforrecord acDataForm, "frm1", acFirst, "Names = ""John"""

Well, when i click one time the method works fine, and the current record is that have the condition. But, when i click second time the current record is the first record whatever is the condition. Any help is helpfull.
 
Probably wont affect it but I would of wrote it like:
DoCmd.SearchForRecord acDataForm, "frm1", acFirst, "[Names] = ""John"
 
SearchForRecord is a macro command that does not exist in VBA, the equivalent might be the DoCmd.FindRecord method, and your code might look like;
Code:
DoCmd.FindRecord "John", , False, , True
This will find the first occurrence of any record in which a field holds the (Exact) string "John" regardless of capitalisation.
 

Users who are viewing this thread

Back
Top Bottom