Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 10-19-2018, 08:37 AM   #16
Minty
AWF VIP
 
Minty's Avatar
 
Join Date: Jul 2013
Location: UK - Wiltshire
Posts: 5,680
Thanks: 138
Thanked 1,531 Times in 1,503 Posts
Minty has a spectacular aura about Minty has a spectacular aura about Minty has a spectacular aura about
Re: Search Record In A Subform

I don't think you are far away,
Code:
[Forms]![Agent]![Passenger_Details].[Form]![sect]
If you click the subform CONTROL change its name to cntPassDetails . This is the control that the subform is contained in - I like to refer to them as subform containers hence my naming convention for them, it makes it obvious its the container not the form - now change it to this

Code:
[Forms]![Agent]![cntPassDetails].[Form]![sect]
It's important to understand the difference between the subform name and the container it sits in, this is where most confusion and errors happen.

__________________
If we have helped please add to our reputation - click the scales symbol on the left, tick 'I approve' and leave a comment.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Minty is offline   Reply With Quote
Old 10-19-2018, 08:44 AM   #17
vagues0ul
Newly Registered User
 
Join Date: Sep 2018
Posts: 100
Thanks: 18
Thanked 2 Times in 1 Post
vagues0ul is on a distinguished road
Re: Search Record In A Subform

Quote:
Originally Posted by Minty View Post

Code:
[Forms]![Agent]![cntPassDetails].[Form]![sect]

still the same error. here is the updated code
Code:
="Passenger_Name = '" & [Forms]![Agent]![cntPassDetails].[Form]![sect] & "'"

am i doing it wrong somewhere?
vagues0ul is offline   Reply With Quote
Old 10-19-2018, 08:56 AM   #18
Minty
AWF VIP
 
Minty's Avatar
 
Join Date: Jul 2013
Location: UK - Wiltshire
Posts: 5,680
Thanks: 138
Thanked 1,531 Times in 1,503 Posts
Minty has a spectacular aura about Minty has a spectacular aura about Minty has a spectacular aura about
Re: Search Record In A Subform

It may be that the macro can't use a subform reference, I don't know I'm afraid as I don't use them.

Add a new button to you form and click the On Click build event option. We're going to write some VBA !

Lets start simple.

All I want you to add is one line of code

Code:
MsgBox "Your Subformvalue is :"  & Me.cntPassDetails.Form!sect
If this works then it's not hard to then use that value to search your form.
This is all assuming you have renamed your sun form container control to cntPassDetails

I'm signing off but if this works then we can progress it later or someone else will hopefully pick it up.

__________________
If we have helped please add to our reputation - click the scales symbol on the left, tick 'I approve' and leave a comment.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Minty is offline   Reply With Quote
Old 10-19-2018, 09:00 AM   #19
vagues0ul
Newly Registered User
 
Join Date: Sep 2018
Posts: 100
Thanks: 18
Thanked 2 Times in 1 Post
vagues0ul is on a distinguished road
Re: Search Record In A Subform

Quote:
Originally Posted by Minty View Post

Code:
MsgBox "Your Subformvalue is :"  & Me.cntPassDetails.Form!sect
MsgBox "Your Subformvalue is :" & Me.cntPassDetails.Form!sect
SECT is on main form not on subform..
vagues0ul is offline   Reply With Quote
Old 10-19-2018, 09:32 AM   #20
Gasman
Access newbie
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 2,574
Thanks: 307
Thanked 401 Times in 386 Posts
Gasman has a spectacular aura about Gasman has a spectacular aura about
Re: Search Record In A Subform

Well you have to use a subform control?

Try

Code:
Forms!Form1!cntSubform1.Form.ID
Where ID is my control on my form in the subform control cntSubform1 that is on main form Form1
__________________
Access novice. Sometimes trying to give something back.
Access 2007
Gasman is offline   Reply With Quote
Old 10-19-2018, 09:36 AM   #21
vagues0ul
Newly Registered User
 
Join Date: Sep 2018
Posts: 100
Thanks: 18
Thanked 2 Times in 1 Post
vagues0ul is on a distinguished road
Re: Search Record In A Subform

Quote:
Originally Posted by Gasman View Post
Well you have to use a subform control?

Try

Code:
Forms!Form1!cntSubform1.Form.ID
Where ID is my control on my form in the subform control cntSubform1 that is on main form Form1
i have attached the db so you can have better idea. the form AGENT is where i have subform and search button.
Attached Files
File Type: accdb NBC.accdb (1.59 MB, 8 views)
vagues0ul is offline   Reply With Quote
Old 10-19-2018, 10:19 AM   #22
Gasman
Access newbie
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 2,574
Thanks: 307
Thanked 401 Times in 386 Posts
Gasman has a spectacular aura about Gasman has a spectacular aura about
Re: Search Record In A Subform

The code you need to see the value is
Code:
Private Sub Command38_Click()
MsgBox "Your Subformvalue is :" & Me.cntPassDetails.Form.Passenger_Name
End Sub
I have not used macroes, except for batch processes, and looking at this, unlikely to.

I suggest you start here.

http://allenbrowne.com/tips.html

There is a search form there and I used that method for one of my DBs.

I do not have the experience to write this for you.

There is a SearchForRecord macro, but that appears to only work on tables, forms, reports and queries. When I tried with your Client_Details form, it complained it was not open, so obviously could not see it within the subform control.

You need to bite the bullet and learn VBA else find a site that uses macroes extensively, as hardly anyone here uses them as far as I know.

Also you will need to use the main form control sect as that is what you are trying to find, after seeing your form.

__________________
Access novice. Sometimes trying to give something back.
Access 2007

Last edited by Gasman; 10-19-2018 at 10:26 AM.
Gasman is offline   Reply With Quote
The Following User Says Thank You to Gasman For This Useful Post:
vagues0ul (10-20-2018)
Old 10-19-2018, 11:05 AM   #23
Gasman
Access newbie
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 2,574
Thanks: 307
Thanked 401 Times in 386 Posts
Gasman has a spectacular aura about Gasman has a spectacular aura about
Re: Search Record In A Subform

https://www.youtube.com/watch?v=iJcB5WkEmb4
__________________
Access novice. Sometimes trying to give something back.
Access 2007
Gasman is offline   Reply With Quote
Old 10-19-2018, 11:37 AM   #24
Gasman
Access newbie
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 2,574
Thanks: 307
Thanked 401 Times in 386 Posts
Gasman has a spectacular aura about Gasman has a spectacular aura about
Re: Search Record In A Subform

Done it !

See pic

The key is I had to go to the subform control first, not the actual control.

However, if I click into Relation in the subform it will find in that, so not ideal.
Attached Images
File Type: png macrofind.PNG (13.8 KB, 11 views)
__________________
Access novice. Sometimes trying to give something back.
Access 2007
Gasman is offline   Reply With Quote
The Following User Says Thank You to Gasman For This Useful Post:
vagues0ul (10-20-2018)
Old 10-20-2018, 01:18 AM   #25
Gasman
Access newbie
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 2,574
Thanks: 307
Thanked 401 Times in 386 Posts
Gasman has a spectacular aura about Gasman has a spectacular aura about
Re: Search Record In A Subform

Here is another way, changing the record source.

https://www.youtube.com/watch?v=N0X8Hg-Sm6A

However ignore the Requery statement, as changing the record source does it automatically. You'd only be doing it twice.

You could start checking Youtube as well as a picture is worth a thousand words. :-)

HTH
__________________
Access novice. Sometimes trying to give something back.
Access 2007

Last edited by Gasman; 10-20-2018 at 01:37 AM.
Gasman is offline   Reply With Quote
The Following User Says Thank You to Gasman For This Useful Post:
vagues0ul (10-20-2018)
Old 10-20-2018, 10:16 AM   #26
vagues0ul
Newly Registered User
 
Join Date: Sep 2018
Posts: 100
Thanks: 18
Thanked 2 Times in 1 Post
vagues0ul is on a distinguished road
Re: Search Record In A Subform

Quote:
Originally Posted by Gasman View Post
Done it !

See pic

The key is I had to go to the subform control first, not the actual control.

However, if I click into Relation in the subform it will find in that, so not ideal.
worked like a charm your comment is a life save .. had to ammed a bit but it worked. THanks a million <3
attaching the ammended macro pic
Attached Images
File Type: png findmacro.png (33.4 KB, 6 views)
vagues0ul is offline   Reply With Quote
Old 10-20-2018, 10:18 AM   #27
vagues0ul
Newly Registered User
 
Join Date: Sep 2018
Posts: 100
Thanks: 18
Thanked 2 Times in 1 Post
vagues0ul is on a distinguished road
Re: Search Record In A Subform

thanks to all senior membes who also helped me. i have also learned about using the vb in code and found two vb codes to make app better.. Thanks you ALL
vagues0ul is offline   Reply With Quote
Old 10-20-2018, 10:32 AM   #28
Gasman
Access newbie
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 2,574
Thanks: 307
Thanked 401 Times in 386 Posts
Gasman has a spectacular aura about Gasman has a spectacular aura about
Re: Search Record In A Subform

You need Find First set to No, else you will never find the next record with the same criteria?
__________________
Access novice. Sometimes trying to give something back.
Access 2007
Gasman is offline   Reply With Quote
Old 10-21-2018, 06:15 AM   #29
vagues0ul
Newly Registered User
 
Join Date: Sep 2018
Posts: 100
Thanks: 18
Thanked 2 Times in 1 Post
vagues0ul is on a distinguished road
Re: Search Record In A Subform

Quote:
Originally Posted by Gasman View Post
You need Find First set to No, else you will never find the next record with the same criteria?
the records only contain single non duplicate value. so it will work for me . thanks for suggestion.

vagues0ul is offline   Reply With Quote
Reply

Tags
form

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Search for Record in a Subform Workingonit Modules & VBA 4 06-10-2015 06:18 AM
Refresh Subform ComboBox Search After Main Form Record Changes CoconutPenang Forms 3 12-01-2010 01:17 PM
Search for record on subform Kenln Modules & VBA 14 07-23-2010 11:14 AM
GoTo Record in subform datasheet from a search on main form jaredg16 Modules & VBA 2 02-03-2007 02:56 PM
GoTo Record in subform datasheet from a search on main form jaredg16 Forms 3 02-03-2007 10:33 AM




All times are GMT -8. The time now is 05:52 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World