Search Record In A Subform (1 Viewer)

vagues0ul

Registered User.
Local time
Today, 10:43
Joined
Sep 13, 2018
Messages
103
Well you have to use a subform control? :banghead:

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.
 

Attachments

  • NBC.accdb
    1.6 MB · Views: 91

Gasman

Enthusiastic Amateur
Local time
Today, 17:43
Joined
Sep 21, 2011
Messages
14,045
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.
 
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 17:43
Joined
Sep 21, 2011
Messages
14,045
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.:banghead:
 

Attachments

  • macrofind.PNG
    macrofind.PNG
    13.8 KB · Views: 89

Gasman

Enthusiastic Amateur
Local time
Today, 17:43
Joined
Sep 21, 2011
Messages
14,045
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
 
Last edited:

vagues0ul

Registered User.
Local time
Today, 10:43
Joined
Sep 13, 2018
Messages
103
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.:banghead:

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
 

Attachments

  • findmacro.png
    findmacro.png
    33.4 KB · Views: 82

vagues0ul

Registered User.
Local time
Today, 10:43
Joined
Sep 13, 2018
Messages
103
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
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:43
Joined
Sep 21, 2011
Messages
14,045
You need Find First set to No, else you will never find the next record with the same criteria?
 

vagues0ul

Registered User.
Local time
Today, 10:43
Joined
Sep 13, 2018
Messages
103
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.
 

Users who are viewing this thread

Top Bottom