Selecting alternatives from a subform

  • Thread starter Thread starter Colin Foster
  • Start date Start date
C

Colin Foster

Hi Group,


I'm trying to use a checkbox ("UseAlt") to determine whether an alternative
contact is used in a form.

The main form contains contact details, with a subform showing alternatives
(having to do it this way as client has requested this add-on 12 months
after DB was designed!). So what I'm trying to do is set things up so that
if the "UseAlt" checkbox is selected, then the contact details from the
Alternatives subform (FrmAltContacts) are used. As there can be more than
one alternative contact, within the subform there is a checkbox ("active")
to indicate which, on this occasion, alternative contact is to be used.

I have come up with the following code attached to the LostFocus property of
the "UseAlt" checkbox.

Private Sub UseAlt_LostFocus()
If Me!UseAlt = -1 Then
WHERE [FrmAltContacts].Form![active]=-1

Me!saluation = [FrmAltContacts].Form![Salutation]
Me!ContactFirstName = [FrmAltContacts].Form![ContactFirstName]
Me!ContactLastName = [FrmAltContacts].Form![ContactLastName]
Me!ContactTitle = [FrmAltContacts].Form![ContactTitle]
End If
End Sub

Unfortunately, it doesn't work & having gone around in a few circles, I
thought that I'd seek assistance, here in the NG.

Any suggestions would be useful.

Regards
Colin Foster
 
What is WHERE [FrmAltContacts].Form![active]=-1 supposed to be?

If it's supposed to be a filter for the form, you need something like

[FrmAltContacts].Form.Filter = "WHERE [FrmAltContacts].Form![active]=-1"
[FrmAltContacts].Form.FilterOn = True

If that's not what you're trying to do, post back with the details.
 
Hi Doug,

Thanks for responding.

What I'm trying to do is on a subform [FrmAltContacts] there are a series of
"Alternative contacts", one of which is "active"(denoted by a "checked"
Checkbox [active] within the subform) can be the selected contact for the
current job. If a checkbox on the main form [UseAlt] is checked, then the
contact details (on the main form)[CustomerFormNew] are replaced by the
"Active" contact from the subform .

The relevent fields are shown in [ ] above

So what I need to be able to do is when the checkbox is selected on the main
form, the Active Alternative's details are moved into the main contact
details.

Does this make things any clearer?

Regards

Colin

Douglas J. Steele said:
What is WHERE [FrmAltContacts].Form![active]=-1 supposed to be?

If it's supposed to be a filter for the form, you need something like

[FrmAltContacts].Form.Filter = "WHERE [FrmAltContacts].Form![active]=-1"
[FrmAltContacts].Form.FilterOn = True

If that's not what you're trying to do, post back with the details.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Colin Foster said:
Hi Group,


I'm trying to use a checkbox ("UseAlt") to determine whether an
alternative
contact is used in a form.

The main form contains contact details, with a subform showing
alternatives
(having to do it this way as client has requested this add-on 12 months
after DB was designed!). So what I'm trying to do is set things up so
that
if the "UseAlt" checkbox is selected, then the contact details from the
Alternatives subform (FrmAltContacts) are used. As there can be more than
one alternative contact, within the subform there is a checkbox
("active")
to indicate which, on this occasion, alternative contact is to be used.

I have come up with the following code attached to the LostFocus property
of
the "UseAlt" checkbox.

Private Sub UseAlt_LostFocus()
If Me!UseAlt = -1 Then
WHERE [FrmAltContacts].Form![active]=-1

Me!saluation = [FrmAltContacts].Form![Salutation]
Me!ContactFirstName = [FrmAltContacts].Form![ContactFirstName]
Me!ContactLastName = [FrmAltContacts].Form![ContactLastName]
Me!ContactTitle = [FrmAltContacts].Form![ContactTitle]
End If
End Sub

Unfortunately, it doesn't work & having gone around in a few circles, I
thought that I'd seek assistance, here in the NG.

Any suggestions would be useful.

Regards
Colin Foster
 
Back
Top