Populate a field in a form from a record in a query

  • Thread starter Thread starter Mack
  • Start date Start date
M

Mack

I have a query that shows part numbers and customers.
I want to be able to click on a part number to open a new form which will
key on that part number. I can open the form with an action on the part
number, but I don't know how to get the form to open to that particular part
number.

How?

Thanks
Mack Neff
 
Mack,

The OpenForm method has a Where argument. Just specify your criteria in that
argument, in the form of a SQL Where clause (without the word "where").
DoCmd.OpenForm FormName, , , "[somefield] = 'abc'"

Assuming when you say you click on a part number, you mean you click on a
value in a list box, then you supply the listbox as part of the argument.
DoCmd.OpenForm FormName, , , "[somefield] = " & Me!lstMyListBox

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
-----Original Message-----
I have a query that shows part numbers and customers.
I want to be able to click on a part number to open a new form which will
key on that part number. I can open the form with an action on the part
number, but I don't know how to get the form to open to that particular part
number.

How?

Thanks
Mack Neff

My suggestion to you is to set up your query with
hyperlinks to the forms you want to see. Open the form
you wish to edit, click "File, Save As" and (if you are
using Word 2000) click the drop down box labeled "Save as
Type" and select Web Page. Don't forget to set the
hyperlinks on your query for the web page file. I hope I
have helped you in some way.

T. D.
age 14
 
Thanks... but not exactly. I am I have a button that launches a query (not a
list box) with a parameter in it. When I enter a parameter, the query
retrieves a three column list of information, the first column of which is
the part number that I wish to click on to open the subject form.


Graham R Seach said:
Mack,

The OpenForm method has a Where argument. Just specify your criteria in that
argument, in the form of a SQL Where clause (without the word "where").
DoCmd.OpenForm FormName, , , "[somefield] = 'abc'"

Assuming when you say you click on a part number, you mean you click on a
value in a list box, then you supply the listbox as part of the argument.
DoCmd.OpenForm FormName, , , "[somefield] = " & Me!lstMyListBox

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html


Mack said:
I have a query that shows part numbers and customers.
I want to be able to click on a part number to open a new form which will
key on that part number. I can open the form with an action on the part
number, but I don't know how to get the form to open to that particular
part
number.

How?

Thanks
Mack Neff
 
Mack,

You said:
"I want to be able to click on a part number to open a new form..."

For the sake of simplicity, I assumed you got the part number from a
listbox. It doesn't matter; you have to get the part number from somewhere.

So if I understand you correctly this time, you click the button, which
fires up a query. You then want to open a form to display the record
associated with the part number you select by clicking the query's
datasheet.

If that's what you want to do, then I'm afraid you're out of luck using that
scenario, because you can't initiate an action from a datasheet.

What you have to do is either of the following:

(a) Use a ListBox or ComboBox to display the record returned by the query.
or
(b) Create another (intermediate) form, to display the records returned by
the query.

One way or the other, you'll need to use a control or form to display the
records, and then write code to open the form to the selected record.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

Mack said:
Thanks... but not exactly. I am I have a button that launches a query (not
a
list box) with a parameter in it. When I enter a parameter, the query
retrieves a three column list of information, the first column of which is
the part number that I wish to click on to open the subject form.


Graham R Seach said:
Mack,

The OpenForm method has a Where argument. Just specify your criteria in that
argument, in the form of a SQL Where clause (without the word "where").
DoCmd.OpenForm FormName, , , "[somefield] = 'abc'"

Assuming when you say you click on a part number, you mean you click on a
value in a list box, then you supply the listbox as part of the argument.
DoCmd.OpenForm FormName, , , "[somefield] = " & Me!lstMyListBox

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html


Mack said:
I have a query that shows part numbers and customers.
I want to be able to click on a part number to open a new form which will
key on that part number. I can open the form with an action on the part
number, but I don't know how to get the form to open to that particular
part
number.

How?

Thanks
Mack Neff
 
Back
Top