Problem with Me. in a continuous form

  • Thread starter Thread starter Julia Boswell
  • Start date Start date
J

Julia Boswell

I've got a problem with some code on a continuous form and I'd appreciate
some help with a solution, as I'm completely stuck!

On the last control of the continuous form (txtPN) there's an after update
event that runs some code and sets the value of a hidden field (me.chkNewPN)
to true or false for that record then sets the focus to the first control on
a new record (txtIDNo).

This works fine except when the user makes a mistake. If he goes back to the
previous record and updates txtPN meaning that the value of chkNewPN needs
to change, the change is applied to the latest record not the incorrect
record.

I hope this makes sense, as it's difficult to explain.

Any ideas on how to fix it?

Thanks

Julia
 
Hi Julia,

It makes sense - sometimes!

What does the true/false value of ChkNewPN depend on? Is it based on
values of other previous fields (as well as txtPN) meeting certain criteria?

When the user goes back to a previous record and changes txtPN, and the
criteria for ChkNewPN changes then it's a quick If..Then...Else fix

in the AfterUpdate event of txtPN put this:

If Me.txtPN = 1 Then
me.chkNewPN = -1 '(true)
Else
Me.chkNewPN = 0 '(false)
End If

That way, every time txtPN is changed on the current record, ChkNewPN is
automatically updated, and you can lose the AfterUpdate event on ChkNewPN

It's easy to fix, but it's not easy when we don't know the criteria for
setting [ChkNewPN]...

make sense?
DubboPete
 
Thanks. Yes that makes sense I think. Unfortunately, it's not as easy as
that. When the after update event on txtPN runs, a hidden form is opened to
search for the value entered. If the form comes up empty (i.e. no value
found) then chNewPN is marked as true, otherwise it's marked as false.

So basically every time a user changes their mind about the value in txtPN
the hidden form opens and the value of chkNewPN should be set depending on
that form. It could go from false, to true, back to false etc.

The code works, but it sets the value in the wrong record.

Julia
DubboPete said:
Hi Julia,

It makes sense - sometimes!

What does the true/false value of ChkNewPN depend on? Is it based on
values of other previous fields (as well as txtPN) meeting certain
criteria?

When the user goes back to a previous record and changes txtPN, and the
criteria for ChkNewPN changes then it's a quick If..Then...Else fix

in the AfterUpdate event of txtPN put this:

If Me.txtPN = 1 Then
me.chkNewPN = -1 '(true)
Else
Me.chkNewPN = 0 '(false)
End If

That way, every time txtPN is changed on the current record, ChkNewPN is
automatically updated, and you can lose the AfterUpdate event on ChkNewPN

It's easy to fix, but it's not easy when we don't know the criteria for
setting [ChkNewPN]...

make sense?
DubboPete

Julia Boswell said:
I've got a problem with some code on a continuous form and I'd appreciate
some help with a solution, as I'm completely stuck!

On the last control of the continuous form (txtPN) there's an after
update event that runs some code and sets the value of a hidden field
(me.chkNewPN) to true or false for that record then sets the focus to the
first control on a new record (txtIDNo).

This works fine except when the user makes a mistake. If he goes back to
the previous record and updates txtPN meaning that the value of chkNewPN
needs to change, the change is applied to the latest record not the
incorrect record.

I hope this makes sense, as it's difficult to explain.

Any ideas on how to fix it?

Thanks

Julia
 
I've just sorted my problem, thanks to your response for making me re-look
at my code. It was a logic error! Typical....

I updated the chkNewPN after I'd moved to a new record. Stupid! All I had to
do was move the line of code up and it works beautifully.

I feel a real plank!!

Thanks for your help.

Julia
DubboPete said:
Hi Julia,

It makes sense - sometimes!

What does the true/false value of ChkNewPN depend on? Is it based on
values of other previous fields (as well as txtPN) meeting certain
criteria?

When the user goes back to a previous record and changes txtPN, and the
criteria for ChkNewPN changes then it's a quick If..Then...Else fix

in the AfterUpdate event of txtPN put this:

If Me.txtPN = 1 Then
me.chkNewPN = -1 '(true)
Else
Me.chkNewPN = 0 '(false)
End If

That way, every time txtPN is changed on the current record, ChkNewPN is
automatically updated, and you can lose the AfterUpdate event on ChkNewPN

It's easy to fix, but it's not easy when we don't know the criteria for
setting [ChkNewPN]...

make sense?
DubboPete

Julia Boswell said:
I've got a problem with some code on a continuous form and I'd appreciate
some help with a solution, as I'm completely stuck!

On the last control of the continuous form (txtPN) there's an after
update event that runs some code and sets the value of a hidden field
(me.chkNewPN) to true or false for that record then sets the focus to the
first control on a new record (txtIDNo).

This works fine except when the user makes a mistake. If he goes back to
the previous record and updates txtPN meaning that the value of chkNewPN
needs to change, the change is applied to the latest record not the
incorrect record.

I hope this makes sense, as it's difficult to explain.

Any ideas on how to fix it?

Thanks

Julia
 
Back
Top