Validation Question

B

Bunky

I have a table that stores the result of an option box. When the data is
loaded, it defaults to a '0'. Then when the operators work the record they
are supposed to select the option that pertains to the record. All of this
is in a subform. Now, what is happening, in their haste, the option is not
getting chosen so the default of '0' is being used.

How can I force the operatior to not exit the record without entering
another option?
 
M

Maurice

You should do a check in the before_update of the form to see if the actual
value is 0, if so show a messagebox and put the focus on the specific field

hth
 
B

Bunky

Unfortunately, I am trying to do exactly that but I am getting syntax errors
in my VB code. Could you be more specfic, please.
 
B

Bunky

Ok - please be kind!

iif(Me.Frame10.Value=0 then docmd.RunMacro[optionedit])

I really do not want to run the macro but do not know how to get a msgbox to
popup without the macro.

Thanks
 
M

Maurice

Ok, here we go:

In your formproperties look for [before update] and click the three little
dots to get to the VB editor (i guess you know that already).

Private Sub Form_BeforeUpdate(Cancel As Integer)

select case me.frame10
case = 0
msgbox "you have to make a choice"
'-> put any additional actions here...
cancel=true
case else
'put action here what needs to be done if a coorect choice is made, or
just leave it blank...
end select

End Sub

The cancel option makes sure the record isn't saved yet.

hth
--
Maurice Ausum


Bunky said:
Ok - please be kind!

iif(Me.Frame10.Value=0 then docmd.RunMacro[optionedit])

I really do not want to run the macro but do not know how to get a msgbox to
popup without the macro.

Thanks

Maurice said:
Post your code so we can walk you trough it
 
B

Bunky

Ok! I copied and pasted the following.

Private Sub OptionChosen_BeforeUpdate(Cancel As Integer)
Select Case Me.Frame10.Value
Case Is = 0
MsgBox "Please Choose a Valid Option"

Cancel = False

End Select

End Sub

I tried Me.Frame10 and several other options but I cannot get it to work.
Any ideas?

Maurice said:
Ok, here we go:

In your formproperties look for [before update] and click the three little
dots to get to the VB editor (i guess you know that already).

Private Sub Form_BeforeUpdate(Cancel As Integer)

select case me.frame10
case = 0
msgbox "you have to make a choice"
'-> put any additional actions here...
cancel=true
case else
'put action here what needs to be done if a coorect choice is made, or
just leave it blank...
end select

End Sub

The cancel option makes sure the record isn't saved yet.

hth
--
Maurice Ausum


Bunky said:
Ok - please be kind!

iif(Me.Frame10.Value=0 then docmd.RunMacro[optionedit])

I really do not want to run the macro but do not know how to get a msgbox to
popup without the macro.

Thanks

Maurice said:
Post your code so we can walk you trough it
--
Maurice Ausum


:

Unfortunately, I am trying to do exactly that but I am getting syntax errors
in my VB code. Could you be more specfic, please.

:

You should do a check in the before_update of the form to see if the actual
value is 0, if so show a messagebox and put the focus on the specific field

hth
--
Maurice Ausum


:

I have a table that stores the result of an option box. When the data is
loaded, it defaults to a '0'. Then when the operators work the record they
are supposed to select the option that pertains to the record. All of this
is in a subform. Now, what is happening, in their haste, the option is not
getting chosen so the default of '0' is being used.

How can I force the operatior to not exit the record without entering
another option?
 
M

Maurice

I assume you have an option frame with two radiobuttons which is called
"Frame10" or did you create a frame with two radiobuttons in there?

In the second case you have to validate the radiobuttons. Let's say your
first radiobutton is called radio1. You have to change your code to:

Private Sub OptionChosen_BeforeUpdate(Cancel As Integer)
if not me.radio then
msgbox "choose option"
end if
End Select

Give some more info on the frame option you have. My guess is that that's
where the problem is.
--
Maurice Ausum


Bunky said:
Ok! I copied and pasted the following.

Private Sub OptionChosen_BeforeUpdate(Cancel As Integer)
Select Case Me.Frame10.Value
Case Is = 0
MsgBox "Please Choose a Valid Option"

Cancel = False

End Select

End Sub

I tried Me.Frame10 and several other options but I cannot get it to work.
Any ideas?

Maurice said:
Ok, here we go:

In your formproperties look for [before update] and click the three little
dots to get to the VB editor (i guess you know that already).

Private Sub Form_BeforeUpdate(Cancel As Integer)

select case me.frame10
case = 0
msgbox "you have to make a choice"
'-> put any additional actions here...
cancel=true
case else
'put action here what needs to be done if a coorect choice is made, or
just leave it blank...
end select

End Sub

The cancel option makes sure the record isn't saved yet.

hth
--
Maurice Ausum


Bunky said:
Ok - please be kind!

iif(Me.Frame10.Value=0 then docmd.RunMacro[optionedit])

I really do not want to run the macro but do not know how to get a msgbox to
popup without the macro.

Thanks

:

Post your code so we can walk you trough it
--
Maurice Ausum


:

Unfortunately, I am trying to do exactly that but I am getting syntax errors
in my VB code. Could you be more specfic, please.

:

You should do a check in the before_update of the form to see if the actual
value is 0, if so show a messagebox and put the focus on the specific field

hth
--
Maurice Ausum


:

I have a table that stores the result of an option box. When the data is
loaded, it defaults to a '0'. Then when the operators work the record they
are supposed to select the option that pertains to the record. All of this
is in a subform. Now, what is happening, in their haste, the option is not
getting chosen so the default of '0' is being used.

How can I force the operatior to not exit the record without entering
another option?
 
B

Bunky

I set up an option frame with 10 options buttons within the frame. The
values are 1 to 10. The result is stored in a field OptionChosen. I have
tried quering against the Frame10, Frame10.Value, OptionChosen with no luck.

Maurice said:
I assume you have an option frame with two radiobuttons which is called
"Frame10" or did you create a frame with two radiobuttons in there?

In the second case you have to validate the radiobuttons. Let's say your
first radiobutton is called radio1. You have to change your code to:

Private Sub OptionChosen_BeforeUpdate(Cancel As Integer)
if not me.radio then
msgbox "choose option"
end if
End Select

Give some more info on the frame option you have. My guess is that that's
where the problem is.
--
Maurice Ausum


Bunky said:
Ok! I copied and pasted the following.

Private Sub OptionChosen_BeforeUpdate(Cancel As Integer)
Select Case Me.Frame10.Value
Case Is = 0
MsgBox "Please Choose a Valid Option"

Cancel = False

End Select

End Sub

I tried Me.Frame10 and several other options but I cannot get it to work.
Any ideas?

Maurice said:
Ok, here we go:

In your formproperties look for [before update] and click the three little
dots to get to the VB editor (i guess you know that already).

Private Sub Form_BeforeUpdate(Cancel As Integer)

select case me.frame10
case = 0
msgbox "you have to make a choice"
'-> put any additional actions here...
cancel=true
case else
'put action here what needs to be done if a coorect choice is made, or
just leave it blank...
end select

End Sub

The cancel option makes sure the record isn't saved yet.

hth
--
Maurice Ausum


:

Ok - please be kind!

iif(Me.Frame10.Value=0 then docmd.RunMacro[optionedit])

I really do not want to run the macro but do not know how to get a msgbox to
popup without the macro.

Thanks

:

Post your code so we can walk you trough it
--
Maurice Ausum


:

Unfortunately, I am trying to do exactly that but I am getting syntax errors
in my VB code. Could you be more specfic, please.

:

You should do a check in the before_update of the form to see if the actual
value is 0, if so show a messagebox and put the focus on the specific field

hth
--
Maurice Ausum


:

I have a table that stores the result of an option box. When the data is
loaded, it defaults to a '0'. Then when the operators work the record they
are supposed to select the option that pertains to the record. All of this
is in a subform. Now, what is happening, in their haste, the option is not
getting chosen so the default of '0' is being used.

How can I force the operatior to not exit the record without entering
another option?
 
M

Maurice

Bunky,

You have to validate the value which you have given to the chk option. So if
your first option is option 0 you have the correct syntax for the validation.
First check the value in the properties of the 'radiobutton'.

Now in the before_update of the form (not the optioncheck) validate your
code as follows:

if me.frame10=0 then
msgbox "enter valid choice"
end if

hth
--
Maurice Ausum


Bunky said:
I set up an option frame with 10 options buttons within the frame. The
values are 1 to 10. The result is stored in a field OptionChosen. I have
tried quering against the Frame10, Frame10.Value, OptionChosen with no luck.

Maurice said:
I assume you have an option frame with two radiobuttons which is called
"Frame10" or did you create a frame with two radiobuttons in there?

In the second case you have to validate the radiobuttons. Let's say your
first radiobutton is called radio1. You have to change your code to:

Private Sub OptionChosen_BeforeUpdate(Cancel As Integer)
if not me.radio then
msgbox "choose option"
end if
End Select

Give some more info on the frame option you have. My guess is that that's
where the problem is.
--
Maurice Ausum


Bunky said:
Ok! I copied and pasted the following.

Private Sub OptionChosen_BeforeUpdate(Cancel As Integer)
Select Case Me.Frame10.Value
Case Is = 0
MsgBox "Please Choose a Valid Option"

Cancel = False

End Select

End Sub

I tried Me.Frame10 and several other options but I cannot get it to work.
Any ideas?

:

Ok, here we go:

In your formproperties look for [before update] and click the three little
dots to get to the VB editor (i guess you know that already).

Private Sub Form_BeforeUpdate(Cancel As Integer)

select case me.frame10
case = 0
msgbox "you have to make a choice"
'-> put any additional actions here...
cancel=true
case else
'put action here what needs to be done if a coorect choice is made, or
just leave it blank...
end select

End Sub

The cancel option makes sure the record isn't saved yet.

hth
--
Maurice Ausum


:

Ok - please be kind!

iif(Me.Frame10.Value=0 then docmd.RunMacro[optionedit])

I really do not want to run the macro but do not know how to get a msgbox to
popup without the macro.

Thanks

:

Post your code so we can walk you trough it
--
Maurice Ausum


:

Unfortunately, I am trying to do exactly that but I am getting syntax errors
in my VB code. Could you be more specfic, please.

:

You should do a check in the before_update of the form to see if the actual
value is 0, if so show a messagebox and put the focus on the specific field

hth
--
Maurice Ausum


:

I have a table that stores the result of an option box. When the data is
loaded, it defaults to a '0'. Then when the operators work the record they
are supposed to select the option that pertains to the record. All of this
is in a subform. Now, what is happening, in their haste, the option is not
getting chosen so the default of '0' is being used.

How can I force the operatior to not exit the record without entering
another option?
 
B

Bunky

Maurice,
The options are 1 to 10; the 0 is a default to show the record has not been
worked yet. Our operators, in their haste are not clicking any option but
going directly to the comments area and manually entering whatever msg is
applicable. The OptionFrame feeds the OptionChosen field on the master so
whatever entry is clicked on, it is propogated in the OptionChosen field on
the master via the Child/Master links on the subform.

What I want to happen is this; if the operator enters comments without an
option being choosen - a message box will popup and remind them to click an
option.

Clear as Mud?

Maurice said:
Bunky,

You have to validate the value which you have given to the chk option. So if
your first option is option 0 you have the correct syntax for the validation.
First check the value in the properties of the 'radiobutton'.

Now in the before_update of the form (not the optioncheck) validate your
code as follows:

if me.frame10=0 then
msgbox "enter valid choice"
end if

hth
--
Maurice Ausum


Bunky said:
I set up an option frame with 10 options buttons within the frame. The
values are 1 to 10. The result is stored in a field OptionChosen. I have
tried quering against the Frame10, Frame10.Value, OptionChosen with no luck.

Maurice said:
I assume you have an option frame with two radiobuttons which is called
"Frame10" or did you create a frame with two radiobuttons in there?

In the second case you have to validate the radiobuttons. Let's say your
first radiobutton is called radio1. You have to change your code to:

Private Sub OptionChosen_BeforeUpdate(Cancel As Integer)
if not me.radio then
msgbox "choose option"
end if
End Select

Give some more info on the frame option you have. My guess is that that's
where the problem is.
--
Maurice Ausum


:

Ok! I copied and pasted the following.

Private Sub OptionChosen_BeforeUpdate(Cancel As Integer)
Select Case Me.Frame10.Value
Case Is = 0
MsgBox "Please Choose a Valid Option"

Cancel = False

End Select

End Sub

I tried Me.Frame10 and several other options but I cannot get it to work.
Any ideas?

:

Ok, here we go:

In your formproperties look for [before update] and click the three little
dots to get to the VB editor (i guess you know that already).

Private Sub Form_BeforeUpdate(Cancel As Integer)

select case me.frame10
case = 0
msgbox "you have to make a choice"
'-> put any additional actions here...
cancel=true
case else
'put action here what needs to be done if a coorect choice is made, or
just leave it blank...
end select

End Sub

The cancel option makes sure the record isn't saved yet.

hth
--
Maurice Ausum


:

Ok - please be kind!

iif(Me.Frame10.Value=0 then docmd.RunMacro[optionedit])

I really do not want to run the macro but do not know how to get a msgbox to
popup without the macro.

Thanks

:

Post your code so we can walk you trough it
--
Maurice Ausum


:

Unfortunately, I am trying to do exactly that but I am getting syntax errors
in my VB code. Could you be more specfic, please.

:

You should do a check in the before_update of the form to see if the actual
value is 0, if so show a messagebox and put the focus on the specific field

hth
--
Maurice Ausum


:

I have a table that stores the result of an option box. When the data is
loaded, it defaults to a '0'. Then when the operators work the record they
are supposed to select the option that pertains to the record. All of this
is in a subform. Now, what is happening, in their haste, the option is not
getting chosen so the default of '0' is being used.

How can I force the operatior to not exit the record without entering
another option?
 
B

Bunky

Maurice,

I humbly apologize. I did not see the instructions to go to the
formproperties. I have been putting the edit on the field and obviously it
did not work. Thank you for your time and efforts. It now works beautifully.

Maurice said:
Ok, here we go:

In your formproperties look for [before update] and click the three little
dots to get to the VB editor (i guess you know that already).

Private Sub Form_BeforeUpdate(Cancel As Integer)

select case me.frame10
case = 0
msgbox "you have to make a choice"
'-> put any additional actions here...
cancel=true
case else
'put action here what needs to be done if a coorect choice is made, or
just leave it blank...
end select

End Sub

The cancel option makes sure the record isn't saved yet.

hth
--
Maurice Ausum


Bunky said:
Ok - please be kind!

iif(Me.Frame10.Value=0 then docmd.RunMacro[optionedit])

I really do not want to run the macro but do not know how to get a msgbox to
popup without the macro.

Thanks

Maurice said:
Post your code so we can walk you trough it
--
Maurice Ausum


:

Unfortunately, I am trying to do exactly that but I am getting syntax errors
in my VB code. Could you be more specfic, please.

:

You should do a check in the before_update of the form to see if the actual
value is 0, if so show a messagebox and put the focus on the specific field

hth
--
Maurice Ausum


:

I have a table that stores the result of an option box. When the data is
loaded, it defaults to a '0'. Then when the operators work the record they
are supposed to select the option that pertains to the record. All of this
is in a subform. Now, what is happening, in their haste, the option is not
getting chosen so the default of '0' is being used.

How can I force the operatior to not exit the record without entering
another option?
 

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