data disappears

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

Guest

We have a setup of one mainform with several subforms, all linked by an HOUR
field in the main form. Each main form is equivalent to an hour of data
sampling. It's important that these forms be bomb-proof for data entry out in
the field, and we've noticed a slight glitch working with them.

Once an HOUR is entered and the corresponding data entered into the
subforms, if someone doesn't navigate forward to a new mainform record with
the navigation bar and instead types in a new HOUR into the mainform, the
subform data disappears. I noticed also that if that first HOUR is entered
back into the next form, the data reappears, but the forms are then in a
different order. I know that the data is still in the tables, but we need
folks to be able to scroll back through each consecutive HOUR's forms at the
end of the day. Is there a way to be sure that this doesn't happen? (and I am
an access rookie).

Thanks for your help in advance. This forum has been a big help so far.
Christine
 
Hi Christine,

The subform data disappears when HOUR is changed because the the subform
data no longer matches the criteria of the linking fields. Things are
behaving as expected so the key for you is to prevent unwanted changes to
the HOUR field. This can be done rather easily by putting up a message box
when an update is being made to the Hour Field after the record has already
been saved:

Using the BeforeUpdate event of the HOUR control - something like this
should work:

If Not Me.NewRecord Then
If MsgBox("Are you sure you want to change this value?", vbYesNo) = vbNo
Then
Me.txtHOUR.Undo
Cancel = True
End If
End If

Another (perhaps better) way to ensure that the value doesn't get changed is
to lock the control -

me.txtHour.locked=true

You could do this in the AfterUpdate event of the form so that after the new
record has been saved it can't be changed. Just remember to unlock it using
the current event on new record:

me.txtHour.locked=not me.NewRecord
 
That sounds wonderfully simple. Thank you!

Christine

Sandra Daigle said:
Hi Christine,

The subform data disappears when HOUR is changed because the the subform
data no longer matches the criteria of the linking fields. Things are
behaving as expected so the key for you is to prevent unwanted changes to
the HOUR field. This can be done rather easily by putting up a message box
when an update is being made to the Hour Field after the record has already
been saved:

Using the BeforeUpdate event of the HOUR control - something like this
should work:

If Not Me.NewRecord Then
If MsgBox("Are you sure you want to change this value?", vbYesNo) = vbNo
Then
Me.txtHOUR.Undo
Cancel = True
End If
End If

Another (perhaps better) way to ensure that the value doesn't get changed is
to lock the control -

me.txtHour.locked=true

You could do this in the AfterUpdate event of the form so that after the new
record has been saved it can't be changed. Just remember to unlock it using
the current event on new record:

me.txtHour.locked=not me.NewRecord

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

We have a setup of one mainform with several subforms, all linked by
an HOUR field in the main form. Each main form is equivalent to an
hour of data sampling. It's important that these forms be bomb-proof
for data entry out in the field, and we've noticed a slight glitch
working with them.

Once an HOUR is entered and the corresponding data entered into the
subforms, if someone doesn't navigate forward to a new mainform
record with the navigation bar and instead types in a new HOUR into
the mainform, the subform data disappears. I noticed also that if
that first HOUR is entered back into the next form, the data
reappears, but the forms are then in a different order. I know that
the data is still in the tables, but we need folks to be able to
scroll back through each consecutive HOUR's forms at the end of the
day. Is there a way to be sure that this doesn't happen? (and I am an
access rookie).

Thanks for your help in advance. This forum has been a big help so
far. Christine
 
Hi Sandra

Finally had a chance to try this, and I'm getting an error message when I
run it. I tried the first option (an error message), and put the code in the
BeforeUpdate event procedure of HOUR, and when I try to enter data, I get the
error message "Method or data member not found" and it takes me to the line
"Me.txtHOUR.Undo". Not sure what this means.

Also, if I do the second option instead, I wasn't sure what you meant by the
'current event on the new record'. Is that the BeforeUpdate event?

Thank you! Excuse my ignorance!
Christine

Sandra Daigle said:
Hi Christine,

The subform data disappears when HOUR is changed because the the subform
data no longer matches the criteria of the linking fields. Things are
behaving as expected so the key for you is to prevent unwanted changes to
the HOUR field. This can be done rather easily by putting up a message box
when an update is being made to the Hour Field after the record has already
been saved:

Using the BeforeUpdate event of the HOUR control - something like this
should work:

If Not Me.NewRecord Then
If MsgBox("Are you sure you want to change this value?", vbYesNo) = vbNo
Then
Me.txtHOUR.Undo
Cancel = True
End If
End If

Another (perhaps better) way to ensure that the value doesn't get changed is
to lock the control -

me.txtHour.locked=true

You could do this in the AfterUpdate event of the form so that after the new
record has been saved it can't be changed. Just remember to unlock it using
the current event on new record:

me.txtHour.locked=not me.NewRecord

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

We have a setup of one mainform with several subforms, all linked by
an HOUR field in the main form. Each main form is equivalent to an
hour of data sampling. It's important that these forms be bomb-proof
for data entry out in the field, and we've noticed a slight glitch
working with them.

Once an HOUR is entered and the corresponding data entered into the
subforms, if someone doesn't navigate forward to a new mainform
record with the navigation bar and instead types in a new HOUR into
the mainform, the subform data disappears. I noticed also that if
that first HOUR is entered back into the next form, the data
reappears, but the forms are then in a different order. I know that
the data is still in the tables, but we need folks to be able to
scroll back through each consecutive HOUR's forms at the end of the
day. Is there a way to be sure that this doesn't happen? (and I am an
access rookie).

Thanks for your help in advance. This forum has been a big help so
far. Christine
 
In the line "Me.txtHOUR.Undo" replace "txtHOUR" with the name of your
control.

The Current event is a form event. Select the form itself (Ctrl-R or Edit-->
Select Form or click the little square at the top left intersection of the
horizontal and vertical rulers). Then look in the event list in the form's
property sheet. The current event fires after each record navigation,
including the first when the form opens.

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Hi Sandra

Finally had a chance to try this, and I'm getting an error message
when I run it. I tried the first option (an error message), and put
the code in the BeforeUpdate event procedure of HOUR, and when I try
to enter data, I get the error message "Method or data member not
found" and it takes me to the line "Me.txtHOUR.Undo". Not sure what
this means.

Also, if I do the second option instead, I wasn't sure what you meant
by the 'current event on the new record'. Is that the BeforeUpdate
event?

Thank you! Excuse my ignorance!
Christine

Sandra Daigle said:
Hi Christine,

The subform data disappears when HOUR is changed because the the
subform data no longer matches the criteria of the linking fields.
Things are behaving as expected so the key for you is to prevent
unwanted changes to the HOUR field. This can be done rather easily
by putting up a message box when an update is being made to the Hour
Field after the record has already been saved:

Using the BeforeUpdate event of the HOUR control - something like
this should work:

If Not Me.NewRecord Then
If MsgBox("Are you sure you want to change this value?",
vbYesNo) = vbNo Then
Me.txtHOUR.Undo
Cancel = True
End If
End If

Another (perhaps better) way to ensure that the value doesn't get
changed is to lock the control -

me.txtHour.locked=true

You could do this in the AfterUpdate event of the form so that after
the new record has been saved it can't be changed. Just remember to
unlock it using the current event on new record:

me.txtHour.locked=not me.NewRecord

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

We have a setup of one mainform with several subforms, all linked by
an HOUR field in the main form. Each main form is equivalent to an
hour of data sampling. It's important that these forms be bomb-proof
for data entry out in the field, and we've noticed a slight glitch
working with them.

Once an HOUR is entered and the corresponding data entered into the
subforms, if someone doesn't navigate forward to a new mainform
record with the navigation bar and instead types in a new HOUR into
the mainform, the subform data disappears. I noticed also that if
that first HOUR is entered back into the next form, the data
reappears, but the forms are then in a different order. I know that
the data is still in the tables, but we need folks to be able to
scroll back through each consecutive HOUR's forms at the end of the
day. Is there a way to be sure that this doesn't happen? (and I am
an access rookie).

Thanks for your help in advance. This forum has been a big help so
far. Christine
 
Worked perfectly... thank you!

Sandra Daigle said:
In the line "Me.txtHOUR.Undo" replace "txtHOUR" with the name of your
control.

The Current event is a form event. Select the form itself (Ctrl-R or Edit-->
Select Form or click the little square at the top left intersection of the
horizontal and vertical rulers). Then look in the event list in the form's
property sheet. The current event fires after each record navigation,
including the first when the form opens.

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Hi Sandra

Finally had a chance to try this, and I'm getting an error message
when I run it. I tried the first option (an error message), and put
the code in the BeforeUpdate event procedure of HOUR, and when I try
to enter data, I get the error message "Method or data member not
found" and it takes me to the line "Me.txtHOUR.Undo". Not sure what
this means.

Also, if I do the second option instead, I wasn't sure what you meant
by the 'current event on the new record'. Is that the BeforeUpdate
event?

Thank you! Excuse my ignorance!
Christine

Sandra Daigle said:
Hi Christine,

The subform data disappears when HOUR is changed because the the
subform data no longer matches the criteria of the linking fields.
Things are behaving as expected so the key for you is to prevent
unwanted changes to the HOUR field. This can be done rather easily
by putting up a message box when an update is being made to the Hour
Field after the record has already been saved:

Using the BeforeUpdate event of the HOUR control - something like
this should work:

If Not Me.NewRecord Then
If MsgBox("Are you sure you want to change this value?",
vbYesNo) = vbNo Then
Me.txtHOUR.Undo
Cancel = True
End If
End If

Another (perhaps better) way to ensure that the value doesn't get
changed is to lock the control -

me.txtHour.locked=true

You could do this in the AfterUpdate event of the form so that after
the new record has been saved it can't be changed. Just remember to
unlock it using the current event on new record:

me.txtHour.locked=not me.NewRecord

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


Rabbit wrote:
We have a setup of one mainform with several subforms, all linked by
an HOUR field in the main form. Each main form is equivalent to an
hour of data sampling. It's important that these forms be bomb-proof
for data entry out in the field, and we've noticed a slight glitch
working with them.

Once an HOUR is entered and the corresponding data entered into the
subforms, if someone doesn't navigate forward to a new mainform
record with the navigation bar and instead types in a new HOUR into
the mainform, the subform data disappears. I noticed also that if
that first HOUR is entered back into the next form, the data
reappears, but the forms are then in a different order. I know that
the data is still in the tables, but we need folks to be able to
scroll back through each consecutive HOUR's forms at the end of the
day. Is there a way to be sure that this doesn't happen? (and I am
an access rookie).

Thanks for your help in advance. This forum has been a big help so
far. Christine
 
Back
Top