restricting data in a field

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

Guest

I want to do the following in a form:

I have a field named [Contact] if the user enters "Internet" then another
field named [Internet Contact] should be enabled. If the user enters anything
else in the [Contact] field box the [Internet Contact] field box must
remained disabled.

Any ideas?

Thanx in advance.
(I will not be able to check your posting(s) until Tuesday, it is quitting
time!)
 
I would do this in the "Contact" change event so that if they change the
field on a record, the Internet Contact field would become enabled or
disabled...


Private Sub Contact_Change()
If Contact= "Internet" Then
[Internet Contact].enabled=true
else
[Internet Contact].enabled=false
End If
End Sub




I'd also do it in the form's current event so that the field will become
enabled or disabled as you scroll from one record to the next....

Private Sub Form_Current()
If Contact= "Internet" Then
[Internet Contact].enabled=true
else
[Internet Contact].enabled=false
End If
End Sub
 
I want to do the following in a form:

I have a field named [Contact] if the user enters "Internet" then
another field named [Internet Contact] should be enabled. If the user
enters anything else in the [Contact] field box the [Internet Contact]
field box must remained disabled.

Any ideas?

Thanx in advance.
(I will not be able to check your posting(s) until Tuesday, it is
quitting time!)

I am going to have to make some assumptions here. Because of some of
your wording I am going to replace the word 'field' above with control
or actually I think they are TextBox's.

In both the Contact_AfterUpdate event and the Form_Current event put
the following:

If Me.Contact = "Internet" then
Me.[Internet Contact].Enable = True
Else
Me.[Internet Contact].Enable = False
End If

If you will accept a couple of suggestions:
1) Spaces in any name is simply a bad practice!
2) Records in tables have 'fields' and forms have controls
that display these 'fields'.
3) What were you planning to do if they spell "Internet"
incorrectly? How about a CheckBox?

HTH
 
The problem there, Rick, is that the change event for "Internet" will fire 9
times. Seems like a lot of overhead.

The change event fires for every change. Typing in one character is a change.


Rick B said:
I would do this in the "Contact" change event so that if they change the
field on a record, the Internet Contact field would become enabled or
disabled...


Private Sub Contact_Change()
If Contact= "Internet" Then
[Internet Contact].enabled=true
else
[Internet Contact].enabled=false
End If
End Sub




I'd also do it in the form's current event so that the field will become
enabled or disabled as you scroll from one record to the next....

Private Sub Form_Current()
If Contact= "Internet" Then
[Internet Contact].enabled=true
else
[Internet Contact].enabled=false
End If
End Sub



--
Rick B



Ricoy-Chicago said:
I want to do the following in a form:

I have a field named [Contact] if the user enters "Internet" then another
field named [Internet Contact] should be enabled. If the user enters anything
else in the [Contact] field box the [Internet Contact] field box must
remained disabled.

Any ideas?

Thanx in advance.
(I will not be able to check your posting(s) until Tuesday, it is quitting
time!)
 
I assumed this was a drop-down combobox with the valid choices.


--
Rick B



Klatuu said:
The problem there, Rick, is that the change event for "Internet" will fire 9
times. Seems like a lot of overhead.

The change event fires for every change. Typing in one character is a change.


Rick B said:
I would do this in the "Contact" change event so that if they change the
field on a record, the Internet Contact field would become enabled or
disabled...


Private Sub Contact_Change()
If Contact= "Internet" Then
[Internet Contact].enabled=true
else
[Internet Contact].enabled=false
End If
End Sub




I'd also do it in the form's current event so that the field will become
enabled or disabled as you scroll from one record to the next....

Private Sub Form_Current()
If Contact= "Internet" Then
[Internet Contact].enabled=true
else
[Internet Contact].enabled=false
End If
End Sub



--
Rick B



I want to do the following in a form:

I have a field named [Contact] if the user enters "Internet" then another
field named [Internet Contact] should be enabled. If the user enters anything
else in the [Contact] field box the [Internet Contact] field box must
remained disabled.

Any ideas?

Thanx in advance.
(I will not be able to check your posting(s) until Tuesday, it is quitting
time!)
 
The [Contact] field is a lookup field. The [internet Contact] is also a
lookup field. They are two different fields in the same table.
thanx.

Rick B said:
I assumed this was a drop-down combobox with the valid choices.


--
Rick B



Klatuu said:
The problem there, Rick, is that the change event for "Internet" will fire 9
times. Seems like a lot of overhead.

The change event fires for every change. Typing in one character is a change.


Rick B said:
I would do this in the "Contact" change event so that if they change the
field on a record, the Internet Contact field would become enabled or
disabled...


Private Sub Contact_Change()
If Contact= "Internet" Then
[Internet Contact].enabled=true
else
[Internet Contact].enabled=false
End If
End Sub




I'd also do it in the form's current event so that the field will become
enabled or disabled as you scroll from one record to the next....

Private Sub Form_Current()
If Contact= "Internet" Then
[Internet Contact].enabled=true
else
[Internet Contact].enabled=false
End If
End Sub



--
Rick B



I want to do the following in a form:

I have a field named [Contact] if the user enters "Internet" then another
field named [Internet Contact] should be enabled. If the user enters
anything
else in the [Contact] field box the [Internet Contact] field box must
remained disabled.

Any ideas?

Thanx in advance.
(I will not be able to check your posting(s) until Tuesday, it is quitting
time!)
 
RicoyChicago,

So much for *my* assumptions! 8^) I have no experience with
LookUp fields so I'll have to sign off of this thread, but
I'll keep reading.
 
Thank you for your help!

I modified the IF that "RuralGuy" provided. I put it in the afterupdate
property for the [Contact] field and I added a msgbox. then I customized
another IF for the [internet source] field in the afterupdate property.

Maybe it is too convoluted but it works!!

THANX!
 
Thank you for your help!

I modified the IF that "RuralGuy" provided. I put it in the
afterupdate property for the [Contact] field and I added a msgbox.
then I customized another IF for the [internet source] field in the
afterupdate property.

Maybe it is too convoluted but it works!!

THANX!

Glad to hear you got it working and thanks for posting back
about your success.
 
Back
Top