From: ANDRLIMO on
I am having a problem with the code that i have written. I can get the last
elseif statement to work but the if and first elseif doesnt want to work
correctly. Below is the code that i used, and any help with this would be
greatly appreciated.

Private Sub Command41_Click()
If Me.APPROVED = "yes" And Me.DISAPPROVED = "0" Then
DoCmd.OpenReport "rptdd1970", acViewPreview
ElseIf Me.APPROVED = "0" And Me.DISAPPROVED = "yes" Then
intanswer = MsgBox("Your request was disapproved.", vbOKOnly)
ElseIf Me.APPROVED = "0" And Me.DISAPPROVED = "0" Then
intanswer = MsgBox("Your request hasn't been reviewed yet.",
vbokayonly)
End If
End Sub

Thanks,

Andrew

From: Douglas J. Steele on
What are APPROVED and DISAPPROVED? If they're check boxes, using quotes is
wrong:

Private Sub Command41_Click()
If Me.APPROVED = True And Me.DISAPPROVED = False Then
DoCmd.OpenReport "rptdd1970", acViewPreview
ElseIf Me.APPROVED = False And Me.DISAPPROVED = True Then
intanswer = MsgBox("Your request was disapproved.", vbOKOnly)
ElseIf Me.APPROVED = False And Me.DISAPPROVED = False Then
intanswer = MsgBox("Your request hasn't been reviewed yet.",vbokayonly)
End If
End Sub



--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

"ANDRLIMO" <u59252(a)uwe> wrote in message news:a648989cf4dc5(a)uwe...
>I am having a problem with the code that i have written. I can get the last
> elseif statement to work but the if and first elseif doesnt want to work
> correctly. Below is the code that i used, and any help with this would be
> greatly appreciated.
>
> Private Sub Command41_Click()
> If Me.APPROVED = "yes" And Me.DISAPPROVED = "0" Then
> DoCmd.OpenReport "rptdd1970", acViewPreview
> ElseIf Me.APPROVED = "0" And Me.DISAPPROVED = "yes" Then
> intanswer = MsgBox("Your request was disapproved.", vbOKOnly)
> ElseIf Me.APPROVED = "0" And Me.DISAPPROVED = "0" Then
> intanswer = MsgBox("Your request hasn't been reviewed yet.",
> vbokayonly)
> End If
> End Sub
>
> Thanks,
>
> Andrew
>


From: Marshall Barton on
ANDRLIMO wrote:

>I am having a problem with the code that i have written. I can get the last
>elseif statement to work but the if and first elseif doesnt want to work
>correctly. Below is the code that i used, and any help with this would be
>greatly appreciated.
>
>Private Sub Command41_Click()
> If Me.APPROVED = "yes" And Me.DISAPPROVED = "0" Then
> DoCmd.OpenReport "rptdd1970", acViewPreview
> ElseIf Me.APPROVED = "0" And Me.DISAPPROVED = "yes" Then
> intanswer = MsgBox("Your request was disapproved.", vbOKOnly)
> ElseIf Me.APPROVED = "0" And Me.DISAPPROVED = "0" Then
> intanswer = MsgBox("Your request hasn't been reviewed yet.",
>vbokayonly)
> End If
>End Sub


What is the field type (in the table) for APPROVED and
DISAPPROVED? It sure looks strange for them to be Text
fields with either "Yes" or "0". More likely they are
Yes/No fields that contain either True or False. If that's
really what you have, then it could be:

Private Sub Command41_Click()
If Me.APPROVED And Not Me.DISAPPROVED Then
DoCmd.OpenReport "rptdd1970", acViewPreview
ElseIf Not Me.APPROVED And Me.DISAPPROVED Then
intanswer = MsgBox("Your request was disapproved.",
vbOKOnly)
ElseIf Not Me.APPROVED And Not Me.DISAPPROVED Then
intanswer = MsgBox("Your request hasn't been
reviewed yet.", vbOKOnly)
End If
End Sub

Note the corrected spelling of vbOKOnly

--
Marsh
MVP [MS Access]
From: ANDRLIMO on
Doug,

Thank you very much that was the problem this is the first time i have ever
done an If statement and i am still in my infancy writing code this was very
helpful and helped correct the problem. Again thanks for the help.

Andrew

Douglas J. Steele wrote:
>What are APPROVED and DISAPPROVED? If they're check boxes, using quotes is
>wrong:
>
>Private Sub Command41_Click()
> If Me.APPROVED = True And Me.DISAPPROVED = False Then
> DoCmd.OpenReport "rptdd1970", acViewPreview
> ElseIf Me.APPROVED = False And Me.DISAPPROVED = True Then
> intanswer = MsgBox("Your request was disapproved.", vbOKOnly)
> ElseIf Me.APPROVED = False And Me.DISAPPROVED = False Then
> intanswer = MsgBox("Your request hasn't been reviewed yet.",vbokayonly)
> End If
>End Sub
>
>>I am having a problem with the code that i have written. I can get the last
>> elseif statement to work but the if and first elseif doesnt want to work
>[quoted text clipped - 15 lines]
>>
>> Andrew

From: bhicks11 via AccessMonster.com on
If they are Yes/No field type - try 0 and -1.

Bonnie
http://www.dataplus-svc.com



ANDRLIMO wrote:
>I am having a problem with the code that i have written. I can get the last
>elseif statement to work but the if and first elseif doesnt want to work
>correctly. Below is the code that i used, and any help with this would be
>greatly appreciated.
>
>Private Sub Command41_Click()
> If Me.APPROVED = "yes" And Me.DISAPPROVED = "0" Then
> DoCmd.OpenReport "rptdd1970", acViewPreview
> ElseIf Me.APPROVED = "0" And Me.DISAPPROVED = "yes" Then
> intanswer = MsgBox("Your request was disapproved.", vbOKOnly)
> ElseIf Me.APPROVED = "0" And Me.DISAPPROVED = "0" Then
> intanswer = MsgBox("Your request hasn't been reviewed yet.",
>vbokayonly)
> End If
>End Sub
>
>Thanks,
>
>Andrew

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/201004/1