T
TishyMouse
Not sure if this is a 'Query' question or a database design question but
hopefully someone will be able to point me in the right direction.
I have a database with 3 tables, Roles, Targets and Actions, defined as
follows:
tblTargets
==========
TargetID (AutoNum, PK)
TargetText (Text)
tblRoles
========
RoleID (AutoNum, PK)
RoleText (Text, unique index)
tblActions
==========
ActionID (AutoNum, PK)
RoleID (Integer)
TargetID (Integer)
ActionText (Text)
TargetID+RoleID = Unique index
For each Target there may be several combinations of Roles/Actions.
I'd like to be able to create a query/form where I can enter a new
ActionText for a combination of RoleText and TargetText, i.e. entering the
text of the role rather than the ID (and also text of the Target rather than
the TargetID). At the moment I can't even get the join between tblRoles and
tblActions to work.
e.g. My query qryRolesActions looks like this:
SELECT tblActions.ActionID, tblActions.TargetID, tblActions.RoleID,
tblRoles.RoleText, tblActions.ActionText
FROM tblRoles LEFT JOIN tblActions ON tblRoles.RoleID = tblActions.RoleID
ORDER BY tblRoles.Role, tblActions.Actions;
This successfully returns the correct dataset for existing data, but when I
try to add a new record by entering the text corresponding to an existing
RoleText it tries immediately to create a new RoleID for this RoleText and
returns a duplicate error
Is there any way round this? Is my database design even correct?
TIA
TishyMouse
hopefully someone will be able to point me in the right direction.
I have a database with 3 tables, Roles, Targets and Actions, defined as
follows:
tblTargets
==========
TargetID (AutoNum, PK)
TargetText (Text)
tblRoles
========
RoleID (AutoNum, PK)
RoleText (Text, unique index)
tblActions
==========
ActionID (AutoNum, PK)
RoleID (Integer)
TargetID (Integer)
ActionText (Text)
TargetID+RoleID = Unique index
For each Target there may be several combinations of Roles/Actions.
I'd like to be able to create a query/form where I can enter a new
ActionText for a combination of RoleText and TargetText, i.e. entering the
text of the role rather than the ID (and also text of the Target rather than
the TargetID). At the moment I can't even get the join between tblRoles and
tblActions to work.
e.g. My query qryRolesActions looks like this:
SELECT tblActions.ActionID, tblActions.TargetID, tblActions.RoleID,
tblRoles.RoleText, tblActions.ActionText
FROM tblRoles LEFT JOIN tblActions ON tblRoles.RoleID = tblActions.RoleID
ORDER BY tblRoles.Role, tblActions.Actions;
This successfully returns the correct dataset for existing data, but when I
try to add a new record by entering the text corresponding to an existing
RoleText it tries immediately to create a new RoleID for this RoleText and
returns a duplicate error
Is there any way round this? Is my database design even correct?
TIA
TishyMouse