If statment from msgbox responce

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

Access 2003
Dim NAAprenda As Integer

NAAprenda = MsgBox("Is this Student Required to provide the APRENDA?",
vbYesNo)
If NAAprenda = True Then
Me!stuAprenda = True
Else
Me!stuAprendaNA = True
End If

stuAprenda and stuAprendaNA are check boxes on the open form

It seems that regardless of answering Yes or No the IF statement always
gives me the "ELSE" result.

What have I got wrong?

Thanks

Dave
 
You want to use the constants VBYes and VBNo to check the values returned by
the MsgBox function. True and False won't do it.

Petr
 
Also, you can make the whole thing simpler:

Dim NAAprenda As Boolean

NAAprenda = VBYes=MsgBox("Is this Student Required to provide the APRENDA?",
vbYesNo)

The way you've got it set up, you're trying to assign a Boolean value to an
integer. You'll get results, but maybe not exactly what you intended. This
will work better.

Petr
 
Dave said:
Access 2003
Dim NAAprenda As Integer

NAAprenda = MsgBox("Is this Student Required to provide the APRENDA?",
vbYesNo)
If NAAprenda = True Then
Me!stuAprenda = True
Else
Me!stuAprendaNA = True
End If

stuAprenda and stuAprendaNA are check boxes on the open form

It seems that regardless of answering Yes or No the IF statement always
gives me the "ELSE" result.

What have I got wrong?

The response is not True or False. Try:

If NAAprenda = vbYes Then
 
Back
Top