Showing selected records on a main form

T

Tony Scullion

I have a main form (frmMainFrom) which shows a farmer and
his/her details. There is approx 400 farmers so far. I
have a created a search form (frmSearch) with subform
(frmSearchSubForm) to search on various fields. If my
search from returns only 19 farmers that match a search
how do I open/filter the main form to show these 19
records only. The code below is what I use to open it for
a single record, can this be amended expanded to cater for
multiple records.

TIA

Tony

********code start

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmMainForm"
stLinkCriteria = "[FarmerID] = " & Me![FarmerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms("frmSearch").Visible = False

********code end
 
H

Harmannus

Hallo,

Sent my a email at (e-mail address removed) and i will send you a example
database with a searchform that does what you want (-:

Regards,

Harmannus, The Netherlands
 
N

nalini

Can I have a copy of this code as well? I'm having this
same problem. Thanks a lot in advance!
-----Original Message-----
Hallo,

Sent my a email at (e-mail address removed) and i will send you a example
database with a searchform that does what you want (-:

Regards,

Harmannus, The Netherlands




I have a main form (frmMainFrom) which shows a farmer and
his/her details. There is approx 400 farmers so far. I
have a created a search form (frmSearch) with subform
(frmSearchSubForm) to search on various fields. If my
search from returns only 19 farmers that match a search
how do I open/filter the main form to show these 19
records only. The code below is what I use to open it for
a single record, can this be amended expanded to cater for
multiple records.

TIA

Tony

********code start

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmMainForm"
stLinkCriteria = "[FarmerID] = " & Me![FarmerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms("frmSearch").Visible = False

********code end


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top