Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can I pass selected record to another form ??

Status
Not open for further replies.

pthakar

Programmer
Feb 28, 2003
38
US
I am new to access forms. I want user to search for (location name)IN ONE FORM(location) AND IF FOUND(based upon the existing record) then he would be able to add/edit multiple records in another form(Leases). Location code is the joining key. Lease# is the primary and Location code is foreign key in lease table

I wonder how I can do that??
Pl. help me.
thanks
 
Actually, Access provides a perfectly reasonable find function, along with form filtering and sorting. You might want to consider using those.

Essentially, you put the cursor in the field you want to search, press ^F, and a search form pops up.

If you want to put in your own, more sophisticated search form, I would still suggest you base it on the primary form, and add a search button that pops up a search form.
 
Hi BeeTee, how would you go about having a button driven search? Brian
 
One option is to use the button wizard to add a 'find' button to your form.

The other option is to delve more deeply into the depths of Access programming and create your own specialized search forms. The details of such a form are implementation dependant. If you can provide specific details, an answer can be provided; without details all that can be suggested is to learn Access.
 
BRH,

If I understand you correctly, once your initial search has resulted in your main form being open with a particular record, you want to be able to have a button open a second, different form linked to the primary key of the main form's record. (Presumably, this will populate a table on the 'many' side of a one-to-many relationship?)

I'm a little bit confused, though, about why your primary key and the foreign key have different names. These two fields contain the same values to link them in the relationship, right?

This code will open a new form using 'Lease#' for the key fields. You'll have to tweak a bit for the foreign key with the mismatched name.

- -

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmNewFormToOpen"

stLinkCriteria = "[Lease#]=" & "'" & Me![Lease#] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

- - - - - - -

Bryan
 
Thank you very much Bryan
It really helped me alot.
Pthakar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top