Hi all
I have a very simple problem but i am highly confused. firstly, a google web search of "DoCmd.Searchforrecord" returns nothing. i've been starting to get suspicious why no one else is interested in this function but me, but here goes:
- sID = Me.ShiftID '--- this is the subforms field, ShiftID
-
ParentsID = Me.Parent.ShiftID '---this is shift viewer's field, ShiftID
-
DoCmd.SearchForRecord acDataForm, "shift viewer", , (ParentsID = sID)
I am under the impression, that my form, "shift viewer" will goto the first record which has a ShiftID of Me.ShiftID (Me being the subform)
i tried putting a breakpoint, on the 3rd line (DoCmd...) and noticed that the values of sID and ParentsID are both as they should be before i do the 3rd line, but when the 3rd line executes, the form "shift viewer" (very quickly, in like 1/4 of a second) runs through all its records, doesnt find the record where the condition is met ( parameter 4) and returns to the record it was originally on... what am i doing wrong?
thanks in advance
The FindRecord method carries out the FindRecord action in Visual Basic.
expression.FindRecord(FindWhat, Match, MatchCase, Search, SearchAsFormatted, OnlyCurrentField, FindFirst)
expression Required. An expression that returns one of the objects in the Applies To list.
FindWhat Required Variant. An expression (expression: Any combination of mathematical or logical operators, constants, functions, and names of fields, controls, and properties that evaluates to a single value. Expressions can perform calculations, manipulate characters, or test data.) that evaluates to text, a number, or a date. The expression contains the data to search for.
Match Optional AcFindMatch.
AcFindMatch can be one of these AcFindMatch constants.
acAnywhere
acEntire default
acStart
If you leave this argument blank, the default constant (acEntire) is assumed.
MatchCase Optional Variant. Use True for a case-sensitive search and False for a search that's not case-sensitive. If you leave this argument blank, the default (False) is assumed.
Search Optional AcSearchDirection.
AcSearchDirection can be one of these AcSearchDirection constants.
acDown
acSearchAll default
acUp
If you leave this argument blank, the default constant (acSearchAll) is assumed.
SearchAsFormatted Optional Variant. Use True to search for data as it's formatted and False to search for data as it's stored in the database. If you leave this argument blank, the default (False) is assumed.
OnlyCurrentField Optional AcFindField.
AcFindField can be one of these AcFindField constants.
acAll
acCurrent default
If you leave this argument blank, the default constant (acCurrent) is assumed.
FindFirst Optional Variant. Use True to start the search at the first record. Use False to start the search at the record following the current record. If you leave this argument blank, the default (True) is assumed.
Remarks
For more information on how the action and its arguments work, see the action topic.
You can leave an optional argument blank in the middle of the syntax, but you must include the argument's comma. If you leave one or more trailing arguments blank, don't use a comma following the last argument you specify.
Example
The following example finds the first occurrence in the records of the name Smith in the current field. It doesn't find occurrences of smith or Smithson.
DoCmd.FindRecord "Smith",, True,, True