automatically updating data within a field

  • Thread starter Thread starter Kay Davies
  • Start date Start date
K

Kay Davies

Hello

I was wondering if anyone could help. I am trying to
automatically complete one field with certain text if
another has 0 entered. I have tried the following:

Private Sub Feverish_Change()
If Feverish.AfterUpdate = "0" Then
SeverityFeverish.Text = "NA"
RelationToVaccineFeverish.Text = "NA"
Else
SeverityFeverish.Value = Null
RelationToVaccineFeverish.Value = Null

End If

End Sub

Nothing happens! I would be grateful if anyone could help.
 
Are SeverityFeverish and RelationToVaccineFeverish bound fields? If not, you
could just make them calculated controls by placing and IIf statement in the
Control Source. If they are bound try,

Private Sub Feverish_AfterUpdate()
If Me.Feverish= 0 Then
SeverityFeverish = "NA"
RelationToVaccineFeverish = "NA"
Else
SeverityFeverish = Null
RelationToVaccineFeverish = Null
End If
End Sub

This will set the values to "NA" or Null. Setting the text is a special
item. The control has to have the focus to work with the .Text property and
as soon as it loses the focus the control will update and the .Text property
will become the .Value property.

Example if the textboxes are not bound to fields:
=IIf(Feverish=0, "NA", Null)
 
Hello

I was wondering if anyone could help. I am trying to
automatically complete one field with certain text if
another has 0 entered. I have tried the following:

Private Sub Feverish_Change()
If Feverish.AfterUpdate = "0" Then
SeverityFeverish.Text = "NA"
RelationToVaccineFeverish.Text = "NA"
Else
SeverityFeverish.Value = Null
RelationToVaccineFeverish.Value = Null

End If

You'r misinterpreting the AfterUpdate - it's an *event*, not a
property of a field. The Change() event fires *at every keystroke*,
i.e. whenever the Feverish control is typed in. I'm not sure what the
datatype of Feverish is, though - text, number, or True/False?

In any case: use the AfterUpdate event of the Feverish control.
Something like

Private Sub Feverish_AfterUpdate()
If Me!Feverish = 0 Then ' use "0" only if it's Text
Me!SeverityFeverish = "NA" ' use the default, not the Text property
Me!RelationToVaccineFeverish = "NA"
Else
....

I do have to question the normalization of your tables: it sounds like
you have fields dependent upon other fields, a violation of normal
form.
 
Thanks to all who replied.

Sounds like I should set it up myself rather than use an ActiveX control.

Thanks again.

Matt
 
Never mind last post. Sent to wrong thread.

Sorry
Matt
"Matt Reed" <wrote in message

Thanks to all who replied.

Sounds like I should set it up myself rather than use an ActiveX control.

Thanks again.

Matt
 
Back
Top