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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validation problems in Access

Status
Not open for further replies.

uttam1

Programmer
Aug 8, 2003
9
IN
Hi all,

I'm having a tough time validating frames and checkboxes in VB. Lets say I have a frame, and I want one value in the frame ( Option Boxes ) checked. Basically, I don't want the frame to have a zero value. How do I do this? The code I'm using now is:


Private Sub Form_BeforeUpdate(Cancel As Integer)

On Error GoTo ErrHandler
If IsNull(Me.Frame22.Value And Me.Frame193.Value And Me.Frame45.Value And Me.Frame93.Value And Me.Frame206.Value And Me.Frame131.Value And Me.Frame146.Value) Then
MsgBox "Please make sure all data has been entered"
Cancel = True
End If

ExitHere:
Exit Sub
ErrHandler:
Debug.Print Err; Err.Description
Resume ExitHere


Where am I going wrong? It's not validating! As for the checkboxes, I have one option's button, when clicked, 3 checkboxes appear, and one of them have to be checked. How do I do this?


Thanks in advance
Uttam

 
ok i'm trying to get clear on your issue: at first you say you have "a frame" but then reference 7 frames in your code? so are you checking for multiple option boxes? or are you trying to check every radio button inside the option box?

your isnull(blah) statement is incorrect syntax. you shouldnt' do it this way, but if you did it would be
Code:
 if isnull(me.fra1) or isnull(me.fra2) or isnull(me.fra2) then
...

INSTEAD--if you want an option box to always have a value, you could just set it's default to something. then's it's ALWAYS SOMETHING.
OR
otherwise you can check to see if it's value = 0
set your option group default to 0 (meaning none of the choices are 'default'). then in your validation code

Code:
if me.optReportChoice = 0 then
   msgbox "Please choose a report!",vbokonly,"MISSING INFO"
   exit sub
end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top