473,781 Members | 2,625 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.FindRecor d ..... 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 18249
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.FindRecor d ..... 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.FindR ec) Then
Set rst = Forms!MainForm! SubForm.Form.Re cordsetclone
rst.FindFirst "OrdDate = #" & Me.FindRec & "#"
If not rst.NoMatch Then
Forms!MainForm! SubForm.Form.Bo okMark = 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
3747
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 bound.
4
1686
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 the records of the table in text boxes at the bottom, and I can scroll thru the records, and a button("Add A New Patient") will allow the user to go to the end of the table and enter data. The other button ("Find A Patient") has been more...
3
11564
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 displayed in unbound boxes on the form, binding the form is Not an option. In the After Update event of the 'Enter Policy Number' textbox I have the following vba code which opens the table and finds the policy nbr, policy nbr is a PrimaryKey/No Dups...
3
6225
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 from the macro on the form I want to find the record in it just sits there and does not run. Could someone tell me how to fix this? Please be specific as I am new to Access.
1
1849
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 acFormBar, acEditMenu, 10, , acMenuVer70 Exit_Find_Record_Click: Exit Sub Err_Find_Record_Click:
11
8420
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 in your expression It only has the option of clicking 'OK', when I do this everything is fine again. I would like to know what is going on and how to fix this problem. Below is parts of the code that I believe the problem is in. The form is...
7
4539
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 records. Should I design a new form for this or can I somehow make this work in the same form. Thanks in advance, john
1
2574
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 find record button on main form i.e Form 1.Master/child relation is already established.Find button works fine with main form.it changes the main form entries and the sub form entries accordingly.this button doesnot work with sub form.this means that...
1
3331
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 the other buttons work, so i believe the form is linked to the table. how can i get the find record button to search the table, not the form itself?
0
9639
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
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
9939
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6729
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
5375
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
5507
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4040
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
2
3633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2870
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.