Subform Frame validation

Derek

Registered User.
Local time
Yesterday, 23:35
Joined
May 4, 2010
Messages
234
Hi All

I have a subform within a form. It has a control named Frame14 with 3 option buttons. It is the continuous subform. What I want to do is put a validation so that the users can't leave any option blank.

There is a Save button in the main form that checks all the validations before data gets saved. So how can I put validation in that to check if the frame value is 0 then display error message.

Thanks
 
If Nz(Me.FrameName, 0) = 0 Then
 
Put in a default frame value. Then it can't ever be 0 on a new record. Back fill your existing data.

The value is stored in Me.Frame14 if you need to check it on existing records
 
I tried the following code but it doesn't check if the frame is left blank.
Code:
 If Nz(Me.sfrmQAsec.Controls("Frame14"), 0) = 0 Then
Exit Sub
End If
 
I am looking for a validation so users are forced to answer each question in Yes,No or N/A
 
? aman are you Derek as well ?
That isn't the correct syntax for referring to a sub form control, from the main form try;
Code:
Me!sfrmQAsec.Form!Frame14
Bookmark this page http://access.mvps.org/access/forms/frm0031.htm for future references for forms and sub forms.
 
Yes we are working on the same project.

Minty, this doesn't work either. It lets me leave few frames blank.
 
If you set a default value on an option group in a form, as far as I am aware, you can't NOT have a value selected. You can't unselect a option group, only select another one.

If you have existing data then simply fill in the missing values directly using an update query, and set a default value in the table for all future records.
 
...There is a Save button in the main form that checks all the validations before data gets saved. So how can I put validation in that to check if the frame value is 0 then display error message...

I think you're missing a couple of things, here. When you leave the Main Form and go to the Subform to fill in your data, the Record on the Main Form is already saved...whether your 'saved' button has been clicked or not!

Likewise, if you left the Main Form, entered data in the Subform, and returned to the Main Form to click the 'save' button, the Record in the Subform has already been saved, as well!

Simply put, validation of data in a Form has to be done in that Form!

You don't really need a 'save' button; you validation, for both Forms, should be done in their respective Form_BeforeUpdate events.

Linq ;0)>
 
I tried the following code but it doesn't check if the frame is left blank.
Code:
 If Nz(Me.sfrmQAsec.Controls("Frame14"), 0) = 0 Then
Exit Sub
End If

You realize this code doesn't actually do anything? Put a message box in there instead of the exit to test.
 
missingling, now I have put the code in subform but it doesn't do anything:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Nz(Me.Frame14, 0) = 0 Then
MsgBox "Incomplete"
Exit Sub
End If
End Sub

Pbadly, I have tried displaying a message box as well but it didn't work as well in the form.

Any help will be much appreciated.
 
Can you attach the db here?
 
I can't attach db as its restricted at work :(
 
How do you have a frame in a continuous form? Surely there is potentially more than one so unless you pick up the correct one it cannot test it's value. It is the 'If' that doesn't work, not the message box.
 
The form update check won't work on existing records unless you have changed data on that particular record.

I'm still mystified how you get a null value on an option group if you set a default value on the form control.
 
Maybe you can't and that's why you can never open the messagebox :cool:
 
...The form update check won't work on existing records unless you have changed data on that particular record.

I think you're right...for this to 'not work' he has to be trying it on an existing Record with no editing being done.

...I'm still mystified how you get a null value on an option group if you set a default value on the form control...

You could only do that if you set it to Null via code...right?

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom