AfterUpdate programming

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

On my form, I have it set up so whenever I select a certain item from a field
list, the next box will either be enabled or disabled. Pretty simple.

But, what I have noticed, is that depending on the last record saved, if I
scroll back through past records, I notice that the box that I am enabling or
disabling, is also in the same state on past records. The data is still
there, but it can be greyed out.

For example, Record one. Entering data through my form, I save my first
record. In this particular record, based on my selection, my second the box
is not greyed out and therefore I had to enter data into this second box.

On the next record, based upon my selection, the second box is greyed out
and I do not have to enter any data into the second box. I then save this
record.

If I go back to the first record, the second box is now greyed out on this
first record, even through the data is there.

It seems as though the previous records on the form, will show this second
box in the state of the very last record saved. Is this a normal thing for
Access to do?
 
It sounds as if you are using a continuous form.

If that is the case, then Access is really showing you multiple copies of the
same control and when you change the control's property in the current row you
automatically see that change reflected in all the other copies that are being
displayed.

So if you are using a continuous form, then this is normal behavior.

If you are using Access 2000 or later, you _MAY_ be able to accomplish your
desired result using conditional formatting. I've found that conditional
formatting has been touchy in some situations and can cause me headaches getting
it to work without interferring with other things I am doing. Unfortunately, I
haven't yet pinned down the situations where it causes me problems. I only use
it sparingly, and if I do use it I test it fairly thoroughly before releasing it
in an application for my users.
 
Thanks John. I am usnig the same form over and over so it is most likely a
continuous form. When I started this database, I knew just enough tog et
going, but not a lot of details. thanks for the help.
 
John has covered one possibility. If you are not using a continuous
Form and you want the "secondary" box on _existing_ records to appear
enabled or disabled according to the value of the "primary" choice
(which you generally would, of course), you need to put code in your
OnCurrent Event to handle this. It would look something like this:

If Me.NewRecord Then
txtSecondaryBox.Enabled = True
Else
Select Case tbxPrimary
Case "This", "That", "Tother"
txtSecondaryBox.Enabled = False
Case Else
txtSecondaryBox.Enabled = True
End Select
End If

On my form, I have it set up so whenever I select a certain item from a field
list, the next box will either be enabled or disabled. Pretty simple.

But, what I have noticed, is that depending on the last record saved, if I
scroll back through past records, I notice that the box that I am enabling or
disabling, is also in the same state on past records. The data is still
there, but it can be greyed out.

For example, Record one. Entering data through my form, I save my first
record. In this particular record, based on my selection, my second the box
is not greyed out and therefore I had to enter data into this second box.

On the next record, based upon my selection, the second box is greyed out
and I do not have to enter any data into the second box. I then save this
record.

If I go back to the first record, the second box is now greyed out on this
first record, even through the data is there.

It seems as though the previous records on the form, will show this second
box in the state of the very last record saved. Is this a normal thing for
Access to do?


Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
Thanks. But I am not sure what "OncCrrentEvent" is. I don't see that under my
options under the Events tab under my bounded box's Properties.

Sorry for being dumb about this.
 
And also, what defines a continuous form? I made one form, and I do all my
record entry in that form. There is only this one form, nothing else.
 
Richard said:
And also, what defines a continuous form? I made one form, and I do all my
record entry in that form. There is only this one form, nothing else.

A continuous form lets you see more than one record at a time with a scrollbar
on the right hand side

EX:
FormHeader
Record
Record
Record
FormFooter

With a non-continuous form you see one record at a time and use the navigation
buttons to move between records.
 
I gotcha. I guess then I am not using a continuous form. I actually have to
click the "next arrow" to see the next record.
 
OnCurrent is an Event of the _Form_, not of the Control. It fires
whenever you navigate to a different record, either new or existing.
It is where you often have to put code that (for existing records)
makes the behaviour of one Control dependent on the contents of
another. You can probably also do what you are trying to do with
conditional formatting, by writing a Function which looks at the value
of the primary control and using it as the formatting condition for
the secondary control, but I personally think that the OnCurrent
approach is "cleaner".

Thanks. But I am not sure what "OncCrrentEvent" is. I don't see that under my
options under the Events tab under my bounded box's Properties.

Sorry for being dumb about this.


Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
Back
Top