If statement

  • Thread starter Thread starter Marie
  • Start date Start date
M

Marie

Using Office 2000. I have a personnel database. Not all
employees have an extension at home office but if they do
then the fldVoiceMail field gets the same value as the
fldWorkExtension field. On a form, how can I code the
fldVoiceMail field to do this: Take the value of the
fldWorkExtension field except if the fldWorkExtension
field is blank let me type in a value for the fldVoiceMail?

Thanks for the help!

Marie
 
In the AfterUpdate event of the textbox that is bound to the fldWorkExtension field you
would set the value of the textbox bound to the fldVoiceMail field. This will change the
voice mail anytime you change the work extension, but will allow you to override it if you
wish.

Example:
Me.txtVoiceMail = Me.txtWorkExtension
 
On the AfterUpdate event of the control where you select the employee, put
code similar to this (assumes that your form's RecordSource contains the
fldWorkExtension and fldVoiceMail fields):

Private Sub EmployeeSelectControl_AfterUpdate()
Dim blnValue As Boolean
blnValue = (Len(Me.fldWorkExtension & "") = 0)
Me.VoiceMailControl.Value = Me.fldWorkExtension
Me.VoiceMailControl.Enabled = blnValue
Me.VoiceMailControl.Locked = Not blnValue
End Sub

The above code will use the value from the fldWorkExtension field to fill in
the value for the control that is bound to fldVoiceMail (change the name
VoiceMailControl to the real name of the control), and then will
enable/unlock (or disable/lock) the control based on whether there is a
value in fldWorkExtension field. Also, I'm using a generic
"EmployeeSelectControl" for the name of the control that you use to select
the employee.
 
Back
Top