Conditional fields

G

Guest

Hi
i was wondering what was the most simple way of doing this:
I have 2 fields called

1) Type of employment which has 3 list values to select from = "self
employed/company/internal"

2) Student ID no.
I want to set a condition that locks the field student id no only if either
self employed or company are selected from the 'type of employment' field -
and displays an error message saying " can only input student id no if type
of employement is internal"

Thanks
 
G

Guest

Connie -

I am assuming that these two fields are on some sort of form. In this
example, I am assuming that the type of employment field is a combo box.

One way to do this is to use the OnEnter event of the student id no field.
When this field is entered, check the value in the employment type field and
see if it is approriate. The code would look something like this: (AIR code,
not tested)

Private Sub Rep_Num_Enter()
If comboEmploymentType = "self-employed" OR comboEmploymentType _
= "company" THEN
msgBox "can only input student id no if type of employement is
internal"
comboEmploymentType.SetFocus
End If
End Sub

HTH!
 
G

Guest

This is the code i put on the on enter property of the field called
Student_ID_no

Private Sub Student_ID_no_Enter()
If [Type of employment] = "Self employed (External)" Or "Company" Then
MsgBox "can only input student id no if Type of employment is LSBU
employed (internal)"
[Type of employment] .SetFocus
End If
End Sub

which has come up with an complie error: invalid or unqualified reference

Any thoughts?
 
G

Guest

Connie --

In order to check an OR condition, the field name must also be repeated.
Try this:
Private Sub Student_ID_no_Enter()
If [Type of employment] = "Self employed (External)" Or _
[Type of employment] = "Company" Then
MsgBox "can only input student id no if Type of employment is LSBU
_ employed (internal)"
[Type of employment] .SetFocus
End If

Connie said:
This is the code i put on the on enter property of the field called
Student_ID_no

Private Sub Student_ID_no_Enter()
If [Type of employment] = "Self employed (External)" Or "Company" Then
MsgBox "can only input student id no if Type of employment is LSBU
employed (internal)"
[Type of employment] .SetFocus
End If
End Sub

which has come up with an complie error: invalid or unqualified reference

Any thoughts?

darrep said:
Connie -

I am assuming that these two fields are on some sort of form. In this
example, I am assuming that the type of employment field is a combo box.

One way to do this is to use the OnEnter event of the student id no field.
When this field is entered, check the value in the employment type field and
see if it is approriate. The code would look something like this: (AIR code,
not tested)

Private Sub Rep_Num_Enter()
If comboEmploymentType = "self-employed" OR comboEmploymentType _
= "company" THEN
msgBox "can only input student id no if type of employement is
internal"
comboEmploymentType.SetFocus
End If
End Sub

HTH!
 
G

Guest

Thanks Darrep . works now :)

darrep said:
Connie --

In order to check an OR condition, the field name must also be repeated.
Try this:
Private Sub Student_ID_no_Enter()
If [Type of employment] = "Self employed (External)" Or _
[Type of employment] = "Company" Then
MsgBox "can only input student id no if Type of employment is LSBU
_ employed (internal)"
[Type of employment] .SetFocus
End If

Connie said:
This is the code i put on the on enter property of the field called
Student_ID_no

Private Sub Student_ID_no_Enter()
If [Type of employment] = "Self employed (External)" Or "Company" Then
MsgBox "can only input student id no if Type of employment is LSBU
employed (internal)"
[Type of employment] .SetFocus
End If
End Sub

which has come up with an complie error: invalid or unqualified reference

Any thoughts?

darrep said:
Connie -

I am assuming that these two fields are on some sort of form. In this
example, I am assuming that the type of employment field is a combo box.

One way to do this is to use the OnEnter event of the student id no field.
When this field is entered, check the value in the employment type field and
see if it is approriate. The code would look something like this: (AIR code,
not tested)

Private Sub Rep_Num_Enter()
If comboEmploymentType = "self-employed" OR comboEmploymentType _
= "company" THEN
msgBox "can only input student id no if type of employement is
internal"
comboEmploymentType.SetFocus
End If
End Sub

HTH!
:

Hi
i was wondering what was the most simple way of doing this:
I have 2 fields called

1) Type of employment which has 3 list values to select from = "self
employed/company/internal"

2) Student ID no.
I want to set a condition that locks the field student id no only if either
self employed or company are selected from the 'type of employment' field -
and displays an error message saying " can only input student id no if type
of employement is internal"

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top