Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making fields required on condition 1

Status
Not open for further replies.

mguidry5

Technical User
Jan 11, 2005
91
0
0
US
I'd like to make a few form fields required if a certain choice is made in an option group. I already have the fields that I would like to be required set to be enabled upon the condition. Is there a way to make them required as well? Here's my code so far:

Code:
Private Sub Frame244_AfterUpdate()

    If Not Shutdown.Value = 3 Then
        Frame143.Enabled = True
        Frame295.Enabled = True
        Parameter.Enabled = True
        MsgBox "You must specify in section 3a. whether   this is an automatic waste feed cutoff" & _
        " or a manual waste feed cutoff.", vbOKOnly, "AWFCO or Manual LWF Cutoff."
        End If
    
    If Me.Frame244.Value = "3" Then
        Frame143.Enabled = False
        Frame295.Enabled = False
        Parameter.Enabled = False
        End If
    
End Sub
 
I don't know if this is what you are looking for but you could try:

If Shutdown.value = 3 then
If [The box that must be filled in] = "" then
Find and Error
End If
End If

Sorry if it is not what you want.
Pete
 
I would recommend to get familiar with the before update event of the form. It fires whenever a save operation is invoked, can be cancelled (setting cancel=true prevents a save), and, in my opinion is ideal for datavalidation. Just check the controls you need based on the selection made, here just a short sample, don't know if it's a complete fit to your challenge:

[tt]select case Me.Frame244.Value
case 1
if trim$(me!txt1.value & "") = "" then
msgbox "missing value in txt1!"
cancel=true
end if
case 2
if trim$(me!txt2.value & "") = "" then
msgbox "missing value in txt2!"
cancel=true
end if
end select[/tt]

Roy-Vidar
 
This is the way frame control works
Code:
Private Sub Frame244_AfterUpdate()
 If Me!Frame244.Value=1 Then
    'Enable/Disable controls
Else
If Me.Frame244.Value = 2 Then
    'Enable/Disable controls
Else
If Me.Frame244.Value = 3 Then
    'Enable/Disable controls
End If
End If
End If
End Sub
For keeping the control required and keep focus use this method
thread702-832930
Regards


Zameer Abdulla
Visit Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top