B
BruceM
I'm not sure in which group I should post this, and I had a hard time coming
up with a descriptive subject line. I have asked about this topic before,
and thought I had come up with a solution, but it seems not.
Here is the situation. I have a Contacts table and a related PhoneNumber
table (Contact ID is the PK/FK). The phone numbers are displayed on a form
in a list box (lstPhone), which gets its data during the form's Current
event:
Me.lstPhone.RowSource = "SELECT Phone FROM tblPhone " & _
"WHERE ContactID = " & Me.ContactID
Phone is a text field, and ContactID a number (autonumber).
I need to designate one number for each contact as the primary number. I
know I can do this with a yes/no field (I will call the field
PrimaryNumber), but there are two considerations. When there is a single
phone number I want it to be the primary one automatically. The other
consideration is that there be only one primary phone number for a contact.
I need a way of preventing two numbers for one contact from both being
designated as the primary one. I could use the Default Value for the
PrimaryNumber (yes/no) field to designate the first record entered as the
primary one. If it is the only record, fine; if not, the user is able to
designate another number as the primary one. The trouble with default value
for the PrimaryNumber field is how to turn it off if the user is entering a
second number (since both can't be primary). Another issue is that if
another number is designated as primary, the previous primary number needs
to have that designation removed (i.e. the PrimaryNumber field needs to be
set to No). The user can be informed by way of a message box.
The logic when entering a phone number (through a pop-up form) is something
like this:
If this is the first number entered for this contact, designate it at the
primary one, since it may be the only number. If there are other phone
numbers for this contact, one of which is designated as primary, clear the
designation from that number and assign it to this one instead, and notify
the user of the change.
The reason for wanting to do this, in case it matters, is that I generate a
report that includes the phone number. The record source for that report is
a query that combines the Contacts table and the PhoneNumber table. If
there are two phone numbers for a contact then there are two records in the
query, and the contact appears twice on the report. I want the contact to
appear just once; to accomplish this I intend to specify True as the
criteria for PrimaryNumber in the report's record source query.
up with a descriptive subject line. I have asked about this topic before,
and thought I had come up with a solution, but it seems not.
Here is the situation. I have a Contacts table and a related PhoneNumber
table (Contact ID is the PK/FK). The phone numbers are displayed on a form
in a list box (lstPhone), which gets its data during the form's Current
event:
Me.lstPhone.RowSource = "SELECT Phone FROM tblPhone " & _
"WHERE ContactID = " & Me.ContactID
Phone is a text field, and ContactID a number (autonumber).
I need to designate one number for each contact as the primary number. I
know I can do this with a yes/no field (I will call the field
PrimaryNumber), but there are two considerations. When there is a single
phone number I want it to be the primary one automatically. The other
consideration is that there be only one primary phone number for a contact.
I need a way of preventing two numbers for one contact from both being
designated as the primary one. I could use the Default Value for the
PrimaryNumber (yes/no) field to designate the first record entered as the
primary one. If it is the only record, fine; if not, the user is able to
designate another number as the primary one. The trouble with default value
for the PrimaryNumber field is how to turn it off if the user is entering a
second number (since both can't be primary). Another issue is that if
another number is designated as primary, the previous primary number needs
to have that designation removed (i.e. the PrimaryNumber field needs to be
set to No). The user can be informed by way of a message box.
The logic when entering a phone number (through a pop-up form) is something
like this:
If this is the first number entered for this contact, designate it at the
primary one, since it may be the only number. If there are other phone
numbers for this contact, one of which is designated as primary, clear the
designation from that number and assign it to this one instead, and notify
the user of the change.
The reason for wanting to do this, in case it matters, is that I generate a
report that includes the phone number. The record source for that report is
a query that combines the Contacts table and the PhoneNumber table. If
there are two phone numbers for a contact then there are two records in the
query, and the contact appears twice on the report. I want the contact to
appear just once; to accomplish this I intend to specify True as the
criteria for PrimaryNumber in the report's record source query.