How do I click on a row on a form and launch new form for that row

D

Dennis

All,

I'm on XP Pro w/ SP3 & Access via XP Office w/ SP3.

I want to create a form where I will enter the customer. The form will then
display the customer's invoices in a table view. I want to click on any one
of the row and have a new form open where I can see the details of that row
or I want to enter new invoice information.

I know how to
1. open an form from another form and pass information to the new form
2. display the data in a table view using a subform.

But how do obtain the row number on which the user clicked and the data
associated with that row?
 
J

Jeanette Cunningham

Hi Dennis,
the key to doing this is to use the primary key of each table.
Make sure the customer invoices form has it's primary key in its record
source query.
When the user clicks the button on that row, you go something like-->

DoCmd.OpenForm "NameOfForm", , , "[PKID] = " & Me!PKID

The form will open to show the details for the invoice selected in the
invoices form.

Note: Replace NameOfForm and PKID with your names.
The above is for a number field
Use "[PKID] = """& Me!PKID & """" for a text field.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
D

Dennis

Jeanette,

Thanks for the info. That will help greatly.

But the bigger question for me is how do I determine "When the user clicks
the button on that row".

I know how to put buttons on a form, but I don't know how many buttons to
put on the customer form. New customers will have zero invoices, older
customers could have between 1 and 100 or more invoices.

How do I create these buttons on the fly in such a way I know which button
was clicked?

If I know the row number of the button, how would I access the data in that
row. Is this were arrays come in? I know how to work with arrays, I just
don't know how to work with arrays in Access. I have the books and I will
start reading on arrays.
 
J

Jeanette Cunningham

This is where a continuous form comes in.
You put one button on the continuous form in the same line or row as the
controls for the data.
When there is more than one line of data for the form, there is a button on
each line.
The code will know exactly which line was clicked and open the next form to
the correct record.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
D

Dennis

Jeanette,

Thank your for your help! I guess I have some reading to do, but now I know
where to look.

I GREATLY appreciate yours and the other MVP's help.
 
D

Dennis

Jeanette,

I have my form working. However, I have to click on the row in which I'm
interested and then I have to click on a command button to launch my data
modification program.

Is there anywhere I can put a somthing on each line so when I click on a
particular line, I can cause continuous form to open another form?
 
J

Jeanette Cunningham

If you put your command button on the end of the row of controls on your
continuous form, there will be a button on each row of the form.
Then you can just click the button for the row you want.

An alternative is to use the double click event of a control in the
continuous part of the form to launch the code to open the next form.
You just double click in the row you want and the next form opens to the
details for that row.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
D

Dennis

Jeanette

Thank you for your assitance. I figured out the command button at the end
of the row by reading other articles. But I did not think about the double
click on any field. Very nice.


--
Dennis


Jeanette Cunningham said:
If you put your command button on the end of the row of controls on your
continuous form, there will be a button on each row of the form.
Then you can just click the button for the row you want.

An alternative is to use the double click event of a control in the
continuous part of the form to launch the code to open the next form.
You just double click in the row you want and the next form opens to the
details for that row.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

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