473,728 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SearchForRecord function problem

15 New Member
Hi all

I have a very simple problem but i am highly confused. firstly, a google web search of "DoCmd.Searchfo rrecord" 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 13503
ADezii
8,834 Recognized Expert Expert
Hi all

I have a very simple problem but i am highly confused. firstly, a google web search of "DoCmd.Searchfo rrecord" 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.Find Record(FindWhat , Match, MatchCase, Search, SearchAsFormatt ed, OnlyCurrentFiel d, 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 AcSearchDirecti on.

AcSearchDirecti on can be one of these AcSearchDirecti on constants.
acDown
acSearchAll default
acUp
If you leave this argument blank, the default constant (acSearchAll) is assumed.


SearchAsFormatt ed 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.

OnlyCurrentFiel d 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.FindRecor d "Smith",, True,, True
Feb 7 '07 #2
NeoPa
32,569 Recognized Expert Moderator MVP
The procedure DoCmd.SearchFor Record 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 New Member
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,569 Recognized Expert Moderator MVP
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 New Member
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.FindRecor d 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
3964
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. Most of the time the function works correctly, but in 2 or 3 cases I have a problem like, search is going on for minutes, and the function does
11
3754
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 (ClassB* b; b->func(); ) the base-class function is called instead of the new function in the derived class. All other similar functions (virtual in the base class and overwritten in the the derived class) work fine, it's just this one function. ...
3
3409
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 VB calback function (passed with initialization) and passes the buffer size (integer type). First I have some problems with __stdcall declaration in VC dll, but I think I solved that problem. Callback function runs in separated thread under main...
5
7693
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 compatible if so how do I work around this date function problem? Ian
8
2088
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 type, I have some elements of this array, thats function pointer member does not need to be initialized to a function. I can't simply initialize it to NULL and I'm not sure if casting NULL(which can be 0 or (void *)0) to the function pointer type
1
1766
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 validate in the same form, If I have two textbox the return doesn't works correctly.. how can I do this? if (document.Form1.TxtFechaIng.value!=''){
3
2617
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 wrapper function. I would prefer to be able to pass the member function as a void* to the static wrapper but I suspect this may not even be possible. Another solution would be option 2 below but I can't figure out the syntax to call obj->*pFn(). ...
3
3060
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 shared_ptr<cBaseas a parameter, and return void. The code was working fine, although I have encountered problems (under a Microsoft compiler, of course - VC 8.0) when I attempt to add callbacks to a class with multiple inheritance. I hate multiple
10
2368
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 code. Public Function fCalcEquation(strEquation As String) As Long Dim MyDB As DAO.Database Dim rstParameters As DAO.Recordset Dim intParamPosition As Integer Dim strParameter As String Dim strValue As String
0
8758
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9422
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9198
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8129
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6716
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6013
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4524
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4792
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3236
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.