Creating a command

  • Thread starter mugziegumz via AccessMonster.com
  • Start date
M

mugziegumz via AccessMonster.com

Brand new with access-
How can I create a command in datasheet form to open another form? Is this
possible? I tried doing the command in datasheet view/form but it didn't work.


I'd like to create a command next to each person's name. So if I clicked on
their last name in datasheet view-it'd open to a new form with lots more
detail.
Step by step instrucitons please! Where do I put the command in properties?
My table name is "Contact Info" my form name is "Contact Details" which give
a more in depth explanation of each employee such as evaluation comments.
Can someone give me a command and tell me where to put it and how to run it?
Shannon
 
G

Graham Mandeno

Hi Shannon

The code to open the other form is:

DoCmd.OpenForm "Contact Details", _
WhereCondition:="ContactID=" & Me.ContactID, _
WindowMode:=acDialog

Replace ContactID with the name of your primary key. If your primary key is
a text field then enclose the value in quotes:
WhereCondition:="ContactID='" & Me.ContactID & "'", _

The WindowMode:=acDialog bit tells Access not to do anything else until the
form you are opening is either closed or made invisible.

Where you put this code depends on your preference. You could create a
command button and add it to its Click event procedure, or you could perhaps
use the DblClick event of the textbox showing the contact name.

Note that you can make a continuous or tabular form which displays many
records but which is much more flexible and powerful than a datasheet form.
 
M

mugziegumz via AccessMonster.com

I don't have a primary key because I had to allow duplicates....can I still
use this command? Where do I put the command? In properties under Macro
Builder, Expression Builder or Code builder? Once I enter this code in....
then what do I do?
As said below- I'm brand new.
Shannon

Graham said:
Hi Shannon

The code to open the other form is:

DoCmd.OpenForm "Contact Details", _
WhereCondition:="ContactID=" & Me.ContactID, _
WindowMode:=acDialog

Replace ContactID with the name of your primary key. If your primary key is
a text field then enclose the value in quotes:
WhereCondition:="ContactID='" & Me.ContactID & "'", _

The WindowMode:=acDialog bit tells Access not to do anything else until the
form you are opening is either closed or made invisible.

Where you put this code depends on your preference. You could create a
command button and add it to its Click event procedure, or you could perhaps
use the DblClick event of the textbox showing the contact name.

Note that you can make a continuous or tabular form which displays many
records but which is much more flexible and powerful than a datasheet form.
Brand new with access-
How can I create a command in datasheet form to open another form? Is this
[quoted text clipped - 13 lines]
it?
Shannon
 
J

John W. Vinson

I don't have a primary key because I had to allow duplicates...

EVERY table *must* have a primary key, otherwise it's not a table, just a
heap.

Stop. Step back. If your table of Clients has multiple records for each
client, your database design is *wrong* and will give you endless trouble!

What's the structure of your table? What information does it contain?
 

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