473,501 Members | 1,581 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

To find a record in the sub form

Dear reader,

How can I find a record in a sub form, the sub form type is DataSheet and
the record collection in the subform are to many to show them all in the
subform window.

What I want is to show a specific record in the subform together with the
other collection of records in the subform. Now I have to scroll to that
record with the vertical scrollbar.

Is there any alternative for the Docmd.FindRecord ..... because this DoCmd
is not working in the subform or I use it on the wrong way.

Tanks for any help.

Kind regards,

Simon
Jul 29 '07 #1
1 18218
Simon wrote:
Dear reader,

How can I find a record in a sub form, the sub form type is DataSheet and
the record collection in the subform are to many to show them all in the
subform window.

What I want is to show a specific record in the subform together with the
other collection of records in the subform. Now I have to scroll to that
record with the vertical scrollbar.

Is there any alternative for the Docmd.FindRecord ..... because this DoCmd
is not working in the subform or I use it on the wrong way.

Tanks for any help.

Kind regards,

Simon

You could add a text field, FindRec, on the main form named MainForm to
collect the search value in subform name SubForm. When found, go to
that record.

Let's say you are going to search for OrdDate in the subform. In the
AfterUpdate event of FindRec have some code like the following.

Dim rst As Recordset
If Not IsNull(Me.FindRec) Then
Set rst = Forms!MainForm!SubForm.Form.Recordsetclone
rst.FindFirst "OrdDate = #" & Me.FindRec & "#"
If not rst.NoMatch Then
Forms!MainForm!SubForm.Form.BookMark = rst.BookMark
else
msgbox "Not Found!"
Endif
'clear out the search field for the next search
Me.FindRec = Null
Endif
rst.Close
set rst = Nothing

I would suggest you paste this code into a code module and highlight
some of the keywords you are unfamiliar with and press the F1.

BTW, you surround Dates with #, Text fields with quotes, number with
nothing. Ex:
rst.FindFirst "Field = #" & Me.Search & "#" 'date
rst.FindFirst "Field = " & Me.Search 'number
rst.FindFirst "Field = '" & Me.Search & "'" 'string
or
rst.FindFirst "Field = """ & Me.Search & """ 'string
Jul 31 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3735
by: HJ | last post by:
Hi all, Consider an Access 2002 run-time application on Windows XP. The controls on a form are locked until the user clicks an Edit button. The form is based on a query and all controls are...
4
1672
by: Christine | last post by:
I am trying to create a data entry form for my database that will enable a user to add a new record or alter an existing record in the table all on one form. So far, the form is set up to display...
3
11512
by: Bob Hynes | last post by:
Hi All, In Access97 I have a linked table(jet backend on a server) which contains 217,432 records today, I have a form on which users enter a policy number which they want to find and have...
3
6197
by: Randy | last post by:
I have been able to set up a Find Record Button on my switchboard to take me to a form with the correct case number by using a parameter query and macro. When I try to run the Find Record button...
1
1830
by: AA Arens | last post by:
I use the undermentioned code to find a record in a predefined "Look In" field: Private Sub Command137_Click() On Error GoTo Err_Find_Record_Click Me.CompanyName.SetFocus DoCmd.DoMenuItem...
11
8387
bhcob1
by: bhcob1 | last post by:
Hi, Whenever I delete a record my command button, the record deletes, a list displaying all records is updated and then a message box appears: Microsoft Access can't find the field 'I' referred to...
7
4527
by: john | last post by:
In my form I have a master table and a details table linked 1xM. I can search through the whole parent table but I also like to be able to search through the child table fields to find parent...
1
2557
by: farhan31 | last post by:
Hello all I have Two tables.Table 1 and table 2.Table 1 has one to many relation with Table 2.I have one main form Form1 based on table 1.On form 1 i have a sub form based on table 2.I have put a...
1
3314
Run2Eat
by: Run2Eat | last post by:
i feel like this is a doofus question... but i've created an access form and added a find record button, but when i use the form, the find record button searches the form itself, not the table. all...
0
7163
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7045
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
7264
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
4628
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...
0
3126
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...
0
3121
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1462
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 ...
1
698
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
329
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.