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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

opening to a specific record in a form from a form

Status
Not open for further replies.

longTommy

Technical User
Dec 19, 2006
9
US
been working on opening a form from another form. (i had to read over that a couple times to make sure i got it right ha ha!).

form setup:

search button and criteria
(self explanatory)

subform
(shows results from the search criteria)

open ItemMaster cmd button
(this is supposed to open ItemMaster to the record i select in the subform)

i want to be able to have a subform with the results from a search (which i've already done). Then to be able to select one row within that subform and click on a command button to open a form, ItemMaster, that has more detailed information on the product.

success that i have had:

using the DoCmd.OpenForm command to open the form, but the criteria i put into the rest of the row opens to a random record within ItemMaster. I think the problem i'm having is referencing the correct record number.

Is there a way i can link two tables together with a query and use the field in one of those tables to open to the correct record in the itemMaster form?

if i need to be more clear, please let me know.

thanks!

tommy
 
Have a look at the 4th argument of the DoCmd.OpenForm method.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
i worked with that, but the subform i have in the form doesn't have a unique primary key that will link to the ItemMaster form.

if i open a query that links two tables together that will eventually get me to a primary key in the ItemMaster form, how can i specifically reference to that query to that table? i've tried a few arguments, but they haven't seemed to work yet.
 
if you want to open the form from a continuous form, you need to put the button in the detail of the contiuous form (so you see it in every row). To build this button, you can use the wizard. You'll get an option if you want to open the new form to show all records, or specific record. Then, at last, you need to select the linking field; this doesn't perse have to be an ID-field (but preferably yes).

Once you have the code, you could also put in the, fi, the double click event of one of the fields.

Pampers [afro]
Keeping it simple can be complicated
 
pampers,

not sure what you mean by

"you need to put the button in the detail of the contiuous form (so you see it in every row)."

that's where my command button is. by the way, what do you mean by "continuous form?"

i tried using the wizard for a button, but it looks for fields that are on the form. it doesn't care about the subform and those are the results that matter to me. but my subform doesn't have the field i need linked to my ItemMaster form
 
to be able to select one row within that subform and click on a command button to open a form
that looks like a contiuous form ie, a form that displays multiple records (look at the form properties).

let's try step by step.
to create the command button, you must use the wizard in the subform (and then in the detail section of the subform, not in the header or footer), then it will show the fields of the subform.


Pampers [afro]
Keeping it simple can be complicated
 
k, i have the cmd button in the subform. i wrote the code and everything for it, but when i go into form view, the button disappears.

i'm trying to make my button on the form detail go to the subform and setfocus on the subform button, and then execute the "openform" command. is that the right track?

thanks again!
 
that is the right track... On click of the button (you don't have to set the focus? do you, the user will click the button), the code will executes. It opens the form on the record related to the record on the subform.


Pampers [afro]
Keeping it simple can be complicated
 
I have a dbase that when the master form is on the record I set the properties in the textbox for the default value of the subform to =[Forms]![Master Form]![Field] and it will automatically use the current record in the master record as a new field on the form within a form.

Not sure if this helps but this is my 2 cents worth!
 
pampers,

i'd like the user to be able to click the button in the subform, but when i go to "form view" it disappears. anything i can do to change that?



oh, BrGenCAJ,

thanks for the suggestion, but that won't work for my situation since my master form will be opened independently of the form i'm building now. but thanks!
 
There is not much you can do about disappearing buttons! Except of course to set its property visible to true.
And you will not see the button, if there are no records to display in the detail section of the form.


Pampers [afro]
Keeping it simple can be complicated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top