473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

SearchForRecord function problem

15
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:

Expand|Select|Wrap|Line Numbers
  1. sID = Me.ShiftID                   '--- this is the subforms field, ShiftID
  2. ParentsID = Me.Parent.ShiftID          '---this is shift viewer's field, ShiftID
  3. 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
Feb 7 '07 #1
5 13477
ADezii
8,834 Expert 8TB
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:

Expand|Select|Wrap|Line Numbers
  1. sID = Me.ShiftID                   '--- this is the subforms field, ShiftID
  2. ParentsID = Me.Parent.ShiftID          '---this is shift viewer's field, ShiftID
  3. 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
Feb 7 '07 #2
NeoPa
32,556 Expert Mod 16PB
The procedure DoCmd.SearchForRecord doesn't exist in Access (Not that I could find any reference to anyway).
ADezii's post gives full information on how to do what you're after.
I hope this resolves your problem.
Feb 8 '07 #3
anansi
15
Yes this is what i want to do, thank you

Since the information was posted i'v been trying to get it all to work. i am failing miserably.. The DoCmd needs to be for the parent of the subform and i cant seem to access the necessary form "shift viewer". The "shift viewer" form is what needs to FindRecord.

So my question isn't about FindRecord anymore, but about getting to the Form, "shift viewer", and being able to perform the method, FindRecord

for example,
Expand|Select|Wrap|Line Numbers
  1. AllForms![shift viewer].Application.FindRecord Me.ShiftID, , True, , True
  2.  
tells me "Object Required". quite confusing

thanks a lot in advance
Feb 13 '07 #4
NeoPa
32,556 Expert Mod 16PB
Look in this Tutorial for help on (Referring to Items on a Sub-Form).
Let us know how you get on :)
Feb 13 '07 #5
anansi
15
Look in this Tutorial for help on (Referring to Items on a Sub-Form).
Let us know how you get on :)
hey. i tried, but am going to try another algorithm.. my problem is that i can accomplish the addressing between the form and subform, but when i try do a DoCmd.FindRecord it does it for the subforms "record set" (not sure if i mean record set), where i actually want the action to be performed on the main form's "record set". switching the focus doesnt help, and i simply dont know why nothing wants to work...

thanks guys
Feb 18 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: rcb845 | last post by:
Hi everybody of the PHP community, I am using the php function "getimagesize()" to access the width/height of an image from the Web. This function should return false if image is not available....
11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
3
by: Tomaz Rotovnik | last post by:
Hi I created very simple dll (vc++) which has three functions (start, stop and initialization). it starts capturing sound from soundblaster and when the buffer is filled with the data, dll calls...
5
by: Ian Davies | last post by:
Dear Access expert I am trying to use an mde application developed in Access2k with Access 2002. I get an Access error box: Function is not available.. Date() etc. Is Access 2002 back...
8
by: Mantorok Redgormor | last post by:
I have ran into a problem where I have a struct that has a member which contains a pointer to function and is initialized to a function in the initializer list. With my array of structs of this...
1
by: Nacho | last post by:
Hello.. I have one problem with my reusable function to validate date.. I want to use this function to all my web project no validate date, but It's works fine if I have one textbox to...
3
by: dice | last post by:
Hi, In order to use an external api call that requires a function pointer I am currently creating static wrappers to call my objects functions. I want to re-jig this so I only need 1 static...
3
by: ryan.mitchley | last post by:
Hi all I have a class (cPort) that is designed to receive objects and, depending on the type, call a handler (callback) in any descendant of a cProcessBlock class. Callback functions take a...
10
by: Constantine AI | last post by:
Hi i am having a little problem with an equation function that was created from all your help previously. The function works fine itself but with a small glitch within it. Here is the function...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.