I'm guessing that the times that don't work are when you don't actually
change the choice in the option group, even though you click on the
selected option button. If yes, the AfterUpdate event isn't occurring
unless you change the value of the option group.
Can you note carefully the actions that you take when it works and when
it doesn't and let's see if it's because an event isn't happening in
some situations? Alternatively, you might consider using the form's
BeforeUpdate event to run the code, as that will fire any time you're
ready to update a record with changes; but also note that it won't
"fire" if no edits are made to the record (edit includes the creation of
a new record).
--
Ken Snell
<MS ACCESS MVP>
Hi Ken,
Done that, and again, sometimes it works & sometimes it doesnt :-(
The option group is on the main form.
I'm going to finish watching "Comic Relief" now (& then to bed!! - here
in the UK it's 22:50), but I'll check back tomorrow to see if you've
had any other ideas, or have spotted what I'm doing wrong!
Regards
Colin
Use the AfterUpdate event of the option group, not the Click event, to
run the code.
This option group is in the main part of the form? Or in the subform?
If it's in the subform, then you cannot use the Me object to reference
the control on the main form. You'd need
Me.Parent!Salutation = Forms![customer form
new]![FrmAltContacts].Form![Salutation]
And, I would rewrite the above this way:
Me.Parent!Salutation = Me.[Salutation]
--
Ken Snell
<MS ACCESS MVP>
Ken,
You are a star!!
This works like a dream
Now I've got that working, I wonder if you could help with the next
stage...
When I select the "Active" record, I need the details to be
transferred into th emain form, so I've put the following code behind
the OnClick property of the option group...
Private Sub SelectContact_Click()
Forms![customer form new]![FrmAltContacts].Requery
Me!Salutation = Forms![customer form
new]![FrmAltContacts].Form![Salutation]
Me!ContactFirstName = Forms![customer form
new]![FrmAltContacts].Form![ContactFirstName]
Me!ContactLastName = Forms![customer form
new]![FrmAltContacts].Form![ContactLastName]
Me!ContactTitle = Forms![customer form
new]![FrmAltContacts].Form![ContactTitle]
Forms![customer form new]![FrmAltContacts].Requery
End Sub
Sometimes it works & the information is transferred into th emain
form (the "me!" part of the above code) and sometimes it doesn't. I
tried to attach it to the "got focus" property of the "Active" action
button, but this didn't help either. I suspect that the problem is
that in the code above, I need to do something else to "tell" the
main form to pick up the "Active" record only. Any idea what this
might be?
Once again, thanks for your help so far.
Regards
Colin
You're using an option group on the form to select which to show.
Let's assume that the option group has a value of 1 when you want
the "active" ones to show, a value of 2 when you want the "inactive"
ones to show, and a value of 3 when you want "all" to show.
The crtierion expression in the query would be something like this:
([forms]![customer form new]![selectcontact] - 2) Or
([forms]![customer form new]![selectcontact] = 3)
--
Ken Snell
<MS ACCESS MVP>
Hi All,
I have a subform where one of the fields is a yes/no checkbox to
indicate whether or not the record is "active": Active returns -1,
inactive 0
On the main form, I need to be able to see either the "active"
records, or the "inactive" records or all records.
So, what I've done is to set up an option group to allow the
selection... one button selects the "Active" and one the
"inactive"... however, that's where the problem starts, I can't get
the third button to show all items.
Basically, the option group result is used by the query that is
used as the source for the subform. I've tried using a statement
within the criteria that says...
IIf([forms]![customer form
new]![selectcontact]=1,<1,[forms]![customer form
new]![selectcontact]) but this then shows all active records,
rather than all
If there is a way that I can achieve this, I'd be really interested
to know!
Regards
Colin Foster