Requires a catagory

N

Nick

I have a sub form that has a text box , and if you enter a number in it
[OTDLhoursused] it is tobe catagorized by selecting one of four radio button
in a radio button frame [Frame 40] holding 5 radio button. The number is
entered but sometime the radio button in not selected , How can I set a
reminder should some not select the botton and then have the reminder go away
once they have selected button and tabing over to the next text box.
 
J

Jeanette Cunningham

Nick,
one way is to use the before update event of the form.
You can test to see if the frame has a value or is null/empty string.
If you find that it has no value, you cancel the update and code a
message box something like this.

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Len(Me.NameOfFrame & vbnullString) =0 Then
Cancel = True
MsgBox "Enter a value for ...")
End If
End Sub


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
N

Nick

I have entered code as shown in the frame40 of the subfrom but it does not
respond I also tried it in form but it too does not work, what other
information do you require?

Private Sub Frame40_BeforeUpdate(Cancel As Integer)
If Len(Me.Frame40 & vbNullString) = 0 Then
Cancel = True
MsgBox "Select overtime type"
End If
End Sub

Jeanette Cunningham said:
Nick,
one way is to use the before update event of the form.
You can test to see if the frame has a value or is null/empty string.
If you find that it has no value, you cancel the update and code a
message box something like this.

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Len(Me.NameOfFrame & vbnullString) =0 Then
Cancel = True
MsgBox "Enter a value for ...")
End If
End Sub


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Nick said:
I have a sub form that has a text box , and if you enter a number in it
[OTDLhoursused] it is tobe catagorized by selecting one of four radio
button
in a radio button frame [Frame 40] holding 5 radio button. The number is
entered but sometime the radio button in not selected , How can I set a
reminder should some not select the botton and then have the reminder go
away
once they have selected button and tabing over to the next text box.
 
J

Jeanette Cunningham

Nick,
not sure what is going on with your form.
Get some more info by stepping through the code.
Put the line
Debug.Print "frame: " & Len(Me.Frame40 & vbNullString)
between the line with private sub and the next line like this:

Private Sub Frame40_BeforeUpdate(Cancel As Integer)
Debug.Print "frame: " & Len(Me.Frame40 & vbNullString)
If Len(Me.Frame40 & vbNullString) = 0 Then

Now click in the far left margin opposite the line Private sub Frame 40 etc
until the line goes red,
this tells the code window to open at this line when the form is running.
Press Ctl + G to turn on the immediate window.
So save the form and open it normally.
Click in frame40 and make a selection.
The code window will open.
Press F8, each press of F8 moves the cursor to the next line of code.
You will be able to see the value for the frame: in the immediate window
after the cursor moves to the next line.
If there are any errors, you will be able to see them happen.

Post back with the results.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Nick said:
I have entered code as shown in the frame40 of the subfrom but it does not
respond I also tried it in form but it too does not work, what other
information do you require?

Private Sub Frame40_BeforeUpdate(Cancel As Integer)
If Len(Me.Frame40 & vbNullString) = 0 Then
Cancel = True
MsgBox "Select overtime type"
End If
End Sub

Jeanette Cunningham said:
Nick,
one way is to use the before update event of the form.
You can test to see if the frame has a value or is null/empty string.
If you find that it has no value, you cancel the update and code a
message box something like this.

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Len(Me.NameOfFrame & vbnullString) =0 Then
Cancel = True
MsgBox "Enter a value for ...")
End If
End Sub


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Nick said:
I have a sub form that has a text box , and if you enter a number in it
[OTDLhoursused] it is tobe catagorized by selecting one of four radio
button
in a radio button frame [Frame 40] holding 5 radio button. The number
is
entered but sometime the radio button in not selected , How can I set a
reminder should some not select the botton and then have the reminder
go
away
once they have selected button and tabing over to the next text box.
 
N

Nick

This is strange as I step through code it start at 1 gose to 2 and at 3 in
the immdiate window the Frame: 1 comes up and then the next step is end If.
(1 Private Sub Form_BeforeUpdate(Cancel As Integer))
(2 Debug.Print "frame: " & Len(Me.Frame40 & vbNullString))
(3 If Len(Me.Frame40 & vbNullString) = 0 Then)
4 Cancel = True
5 MsgBox "Select overtime type"
(End If)
End Sub

frame: 1
 
J

Jeanette Cunningham

That's right.
If the frame has a value, then the cancel line and the msgbox line are
skipped.
The code looks at the If line, works out if there is a value for the frame
or not.
If the frame has no value, the code would go to the cancel line followed by
the msgbox line.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
N

Nick

If I tab through the form to add a new record with out selecting a catagor
it does not notify of my error. If the code is correct then why is it not
working?
 
N

Nick

I think I may have found the problem, the option within the the frame are
perhaps not part of frame40. I have option 43 through 53. I do not know how
to correct so that one of the option must be selected.
 
J

Jeanette Cunningham

Nick said:
I think I may have found the problem, the option within the the frame are
perhaps not part of frame40. I have option 43 through 53. I do not know
how
to correct so that one of the option must be selected.
 
J

Jeanette Cunningham

Nick,
there is a before update event for the form
and also a before update event for text boxes, combos, frames . . .

That code needs to go on the before update event for the form.
Open the form in design view.
Click on the small square at top left of the form until that square is
black.
This shows that you have selected the form (not controls on the form).
On the property dialog for the form, on the event tab, find the before
update event and put the code there like this
You can type a left square bracket into the box at the right of the before
update event in the property dialog
Access will fill in the line.
go Ctl + F2 to open the code window at exactly that spot and paste in the
code below
Paste the code between the line
Private Sub Form_BeforeUpdate(Cancel As Integer)
and the line
End Sub


Debug.Print "frame: " & Len(Me.Frame40 & vbNullString)
If Len(Me.Frame40 & vbNullString) = 0 Then
Cancel = True
MsgBox "Select overtime type"
End If


With the code on the before update event for the form instead of the frame,
the form will check its before update event before the record is saved.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

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