on click error message

A

amjjam

Hi,

I have a contacts form with 3 tabs: 1) contact’s name and business
information; 2) communications – a subform; and 3) contact’s general
information. The communications subform requires the ContactsID number so
data is linked and stored appropriately in the underlying communications
table. Form tabs 1 and 3 have a task button labeled View Contact Fact Sheet.
I have linked the button to an on click macro to open the Contact Fact Sheet
in print preview. It reads:

Action: OpenReport
Report Name: Contact Fact Sheet
View: Print Preview
Filter: (blank)
Where Condition: [ContactsID]=[Forms]![Contacts]![ContactsID]
Window Mode: Normal

When I click on the button to open the contact fact sheet, I get an error
message which reads: The specified field ‘[ContactsID]’ could refer to more
than one table listed in the FROM clause of your SQL statement. Can anyone
tell me how to get this button to work? When I hit the help button on the
error message, it indicates that the SQL statement must specify which table
the ContactsID should be drawn from. I tried using code builder to insert:

Private Sub ViewContactCommand_Click()
SELECT Contacts.ContactsID FROM Contacts, [ContactsID];
End Sub

That gives me a syntax error and I don’t know if I need to delete the macro
altogether to test run that appropriately. Working with Access 2003 is new
for me, so if you can give detailed instructions, I’d appreciate it. I’m not
sure what the full module would look like for this OpenReport command, if I
need to write one rather than use a macro. Thanks! ~ amjjam
 
K

Ken Snell [MVP]

The error message suggests that the query being used as the Record Source by
the report contains two or more fields named ContactsID. I assume that one
of those fields is the one you want to use. So qualify the field name with
the table name corresponding to the table in which the field is located
(note: this table must be in the query's tables that are providing the
data):

Where Condition:
[NameOfTheTable].[ContactsID]=[Forms]![Contacts]![ContactsID]
 
A

amjjam

Perfect! Thanks, Ken! ~ amjjam

Ken Snell said:
The error message suggests that the query being used as the Record Source by
the report contains two or more fields named ContactsID. I assume that one
of those fields is the one you want to use. So qualify the field name with
the table name corresponding to the table in which the field is located
(note: this table must be in the query's tables that are providing the
data):

Where Condition:
[NameOfTheTable].[ContactsID]=[Forms]![Contacts]![ContactsID]

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


amjjam said:
Hi,

I have a contacts form with 3 tabs: 1) contact's name and business
information; 2) communications - a subform; and 3) contact's general
information. The communications subform requires the ContactsID number so
data is linked and stored appropriately in the underlying communications
table. Form tabs 1 and 3 have a task button labeled View Contact Fact
Sheet.
I have linked the button to an on click macro to open the Contact Fact
Sheet
in print preview. It reads:

Action: OpenReport
Report Name: Contact Fact Sheet
View: Print Preview
Filter: (blank)
Where Condition: [ContactsID]=[Forms]![Contacts]![ContactsID]
Window Mode: Normal

When I click on the button to open the contact fact sheet, I get an error
message which reads: The specified field '[ContactsID]' could refer to
more
than one table listed in the FROM clause of your SQL statement. Can anyone
tell me how to get this button to work? When I hit the help button on the
error message, it indicates that the SQL statement must specify which
table
the ContactsID should be drawn from. I tried using code builder to insert:

Private Sub ViewContactCommand_Click()
SELECT Contacts.ContactsID FROM Contacts, [ContactsID];
End Sub

That gives me a syntax error and I don't know if I need to delete the
macro
altogether to test run that appropriately. Working with Access 2003 is new
for me, so if you can give detailed instructions, I'd appreciate it. I'm
not
sure what the full module would look like for this OpenReport command, if
I
need to write one rather than use a macro. Thanks! ~ amjjam
 

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