In a form or report you could have an unbound text box with a ControlSource of:
=Left([LoopTag],4) & Right([LoopTag],4)
You'd no longer need to set the Defaultvalue property for this control of
course as once you enter the LoopTag value the unbound control would show the
computed value.
In a query you'd do it in a similar way:
SELECT Left(LoopTag,4) & Right(LoopTag,4) AS MasterLoop, LoopTag
FROM YourTable;
To do this in query design view enter the following in the 'field' row of a
blank column:
MasterLoop: Left([LoopTag],4) & Right([LoopTag],4)
An Alternative approach would be to have the MasterLoop field as at present
in the table, plus a Tag field with just the A,B,C etc. You'd then compute
the MasterLoop with:
=Left([LoopTag],4) & [Tag] & Right([LoopTag],4)
The MasterLoop and Tag columns should be the composite primary key of the
table or otherwise indexed uniquely. You could then still set the
MasterLoop's DefaultValue as I described and you'd just need to enter A,B,C
in the Tag field when entering a new record until you wish to change the
MasterLoop value to a new one.
I should emphasise, however, that this is probably far from the right way to
do things. I suspect that the table really needs decomposing into at least
two tables, one with one row per MasterLoop value and another referencing it,
containing a column of the Tag values. Without knowing what the entity types
being modelled are, however, its not possible to be definitive about this.
Ken Sheridan
Stafford, England
> Thanks Ken
>
> How would I 'compute' the MASTERLOOP field in the table ?
Black Knight - 15 Mar 2006 02:15 GMT
> In a form or report you could have an unbound text box with a
> ControlSource of:
[quoted text clipped - 44 lines]
> Ken Sheridan
> Stafford, England
Ken
Thank you so much for your replies and your help.
I've managed to concatenate each field as you suggested using a query and
then making a form from the query.
I think the reason for the MASTERLOOP field to be typed in is because its
used in other tables.
If this field is derived using a query or a form then the other tables would
not work properly ?
If I can be so bold I can give further information if you were able to spare
your valuable time to help out.
Many Thanks
Ken Sheridan - 15 Mar 2006 10:55 GMT
It would still be possible to reference the key of another table even without
the MasterLoop column; you'd use the same expression as is used to compute
the value from the LoopTag value. However the best way would be the
alternative I suggested, of keeping the MasterLoop column and having a Tag
column with just the A,B,C etc, and then computing theLoopTag value. This
also eliminates the redundancy, which is important because it can otherwise
leave the door open to update anomalies. With the present setup it is
possible to have a LoopTag value and a MasterLoop value in the same row with
the common elements differing. By elimination the redundancy this is no
longer possible.
You can easily populate a Tag column from the existing data with a simple
UPDATE query once you've added the Tag column to the table definition:
UPDATE YourTable
SET Tag = MID(LoopTag,5,1);
Once you are satisfied that the tag column contains the correct values the
LoopTag column can be deleted from the table definition. The MasterLoop and
Tag columns should then be (together) indexed uniquely, which you do from the
View|Indexes menu item in table design view.
BTW I got the expression wrong for computing the LoopTag; it should have
been the following of course:
=Left([MasterLoop],4) & [Tag] & Right(MasterLoop],4)
Feel free to post any more questions you have on this.
Ken Sheridan
Stafford, England
> Ken
>
[quoted text clipped - 13 lines]
>
> Many Thanks