If statment from msgbox responce

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
 
P

Petr Danes

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
 
P

Petr Danes

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
 
M

Marshall Barton

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
 

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