Double click to open form and copy ID field

D

DavisGail

I am working in Access 2003. I know exactly what I want to do, just can't
get it to work correctly.

I have a continuous form that is built off a query that prompts for
LastName. The form (SRBInfo) lists all the current documents by the employee
name. The list includes a DocID (which is an autonumber).

I want to double click on the DocID, open another form (pubUpdate) and set
the SRBId field to the value that was in the DocID.

A little background: I have two separate tables of information. I need to
link the two, however there are no fields that are unique. So I set the
primary key in table 1 (DocID) to the field in the second table (SRBId).
This way I can create the relationship. If there is a better way to do this,
I'm all ears.
 
T

Tom van Stiphout

On Tue, 2 Mar 2010 06:49:01 -0800, DavisGail

In that field DocID's DoubleClick event, write:
DoCmd.OpenForm "SRBInfo", , , "SRBId=" & Me.DocID

-Tom.
Microsoft Access MVP
 
M

Maurice

You could use the openargs for this:

On the doubleclick event place the following code line

DoCmd.OpenForm "yourformname", , , , , , Me.DocID

replace the yourformname for the name of your actual form you want to open.

In the open event of the form your are opening you can check what openargs
will return like

if me.openargs <>"" then
me.idfield=openargs
else
'do something else or nothing
end if

where you replace the me.idfield for the field that should get the new id
value you want to place in the form.

The fact that you don't have a unique key might cause problems because the
tables aren't normalized. You should have a pk in the first table and a fk in
the other table. Join the two together via the relatonshipwindow and you are
good to go.

Access has a formwizard which does exactly what you want if the joins are
correct. In this situation there is no join so you have to use the
alternative ways. However i my opinion it's better to set the tables up
normalized while you still can because if you go ob using it this way the
regret will come later. So give it a thought.
Questions; you know where to find us.

hth
 
D

De Jager

DavisGail said:
I am working in Access 2003. I know exactly what I want to do, just can't
get it to work correctly.

I have a continuous form that is built off a query that prompts for
LastName. The form (SRBInfo) lists all the current documents by the
employee
name. The list includes a DocID (which is an autonumber).

I want to double click on the DocID, open another form (pubUpdate) and set
the SRBId field to the value that was in the DocID.

A little background: I have two separate tables of information. I need
to
link the two, however there are no fields that are unique. So I set the
primary key in table 1 (DocID) to the field in the second table (SRBId).
This way I can create the relationship. If there is a better way to do
this,
I'm all ears.
 

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