Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Add some stuff to code

Discussion in 'Information Technology' started by Chey, Jul 28, 2006.

Tags:
  1. Chey

    Chey
    Expand Collapse
    Guest

    I have this code
    Private Sub chkApproved_Click()
    If Me.chkapproved = True Then
    DoCmd.SendObject acSendNoObject, , , to:=, Subject:=[TA Number],
    MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    to " & [Destination] & " on " & [Date Leave] & " " & "has been approved.",
    EditMessage:=False
    End If

    If Me.chknotapproved = True Then
    DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    to " & [Destination] & " on " & [Date Leave] & " " & "has not been approved.
    Pls contact me at your earliest convince." & " " & "Thx Lewis",
    EditMessage:=False
    End If

    If Me.chkapproved = True Then
    DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    [First and Last Name], , False
    DoCmd.PrintOut
    DoCmd.Close
    End If

    End Sub

    I have the two check boxes. Travel Approved and Revised. When a supervisor
    checks Travel Approved then It send an email to the traveler and to me.
    However If the box Revised is checked which is automatically done when they
    revise there trip. I would Like the Email to read a little differently. I
    do I add this step?
    I would like the email to the Traveler to be something around the lines of
    "Your revision to [Desination] on [Date Leave] has been approved.

    and the one sent to me to say something like [First and Last Name]'s trip
    to [Destination] on [Date Leave] has been revised and approved. Please fix
    changes made.




    Thanks
    Chey
     
  2. Loading...


  3. Biz Enhancer

    Biz Enhancer
    Expand Collapse
    Guest

    Hi Chey,

    If I am reading you right then a nested if statement should help.

    If Me.chkapproved = True Then
    If Me.chkrevised = True Then
    ' DoStuff where both chkboxes =true
    Else
    ' DoStuff where chkapproved=true and chkrevised=false
    End if
    Else
    ' DoStuff where chkapproved=false
    End if

    Nest as many conditions as you like, but be aware that it can give a bit of
    brain strain if to many are nested.

    Hope it helps.

    Regards,
    Nick.

    "Chey" wrote:

    > I have this code
    > Private Sub chkApproved_Click()
    > If Me.chkapproved = True Then
    > DoCmd.SendObject acSendNoObject, , , to:=, Subject:=[TA Number],
    > MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    > to " & [Destination] & " on " & [Date Leave] & " " & "has been approved.",
    > EditMessage:=False
    > End If
    >
    > If Me.chknotapproved = True Then
    > DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    > MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    > to " & [Destination] & " on " & [Date Leave] & " " & "has not been approved.
    > Pls contact me at your earliest convince." & " " & "Thx Lewis",
    > EditMessage:=False
    > End If
    >
    > If Me.chkapproved = True Then
    > DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    > Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    > DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    > [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    > [First and Last Name], , False
    > DoCmd.PrintOut
    > DoCmd.Close
    > End If
    >
    > End Sub
    >
    > I have the two check boxes. Travel Approved and Revised. When a supervisor
    > checks Travel Approved then It send an email to the traveler and to me.
    > However If the box Revised is checked which is automatically done when they
    > revise there trip. I would Like the Email to read a little differently. I
    > do I add this step?
    > I would like the email to the Traveler to be something around the lines of
    > "Your revision to [Desination] on [Date Leave] has been approved.
    >
    > and the one sent to me to say something like [First and Last Name]'s trip
    > to [Destination] on [Date Leave] has been revised and approved. Please fix
    > changes made.
    >
    >
    >
    >
    > Thanks
    > Chey[/color]
     
  4. Chey

    Chey
    Expand Collapse
    Guest

    so I did everything you said and when I went to go run it it says block end
    without end if.

    Private Sub chkApproved_Click()
    If Me.chkapproved = True Then
    If Me.Revised = True Then
    DoCmd.SendObject acSendNoObject, , , to:=, Subject:=[TA
    Number], MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your
    REVISED travel to " & [Destination] & " on " & [Date Leave] & " " & "has been
    approved.", EditMessage:=True
    Else
    DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    to " & [Destination] & " on " & [Date Leave] & " " & "has been approved.",
    EditMessage:=False
    End If
    If Me.chkapproved = True Then
    If Me.Revised = True Then
    DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    [First and Last Name], [First and Last Names] & "'s" & " " & "trip to" & " "
    & [Destination] & " " & "REVISED has been approved please make the following
    changes.", EditMessage:=False
    DoCmd.PrintOut
    DoCmd.Close
    Else
    DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    [First and Last Name], [First and Last Names] & "'s" & " " & "trip to" & " "
    & [Destination] & " " & "has been approved please book travel.", False
    DoCmd.PrintOut
    DoCmd.Close
    End If
    End Sub

    Thanks for your time.

    "Biz Enhancer" wrote:
    [color=blue]
    > Hi Chey,
    >
    > If I am reading you right then a nested if statement should help.
    >
    > If Me.chkapproved = True Then
    > If Me.chkrevised = True Then
    > ' DoStuff where both chkboxes =true
    > Else
    > ' DoStuff where chkapproved=true and chkrevised=false
    > End if
    > Else
    > ' DoStuff where chkapproved=false
    > End if
    >
    > Nest as many conditions as you like, but be aware that it can give a bit of
    > brain strain if to many are nested.
    >
    > Hope it helps.
    >
    > Regards,
    > Nick.
    >
    > "Chey" wrote:
    >[color=green]
    > > I have this code
    > > Private Sub chkApproved_Click()
    > > If Me.chkapproved = True Then
    > > DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    > > MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    > > to " & [Destination] & " on " & [Date Leave] & " " & "has been approved.",
    > > EditMessage:=False
    > > End If
    > >
    > > If Me.chknotapproved = True Then
    > > DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    > > MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    > > to " & [Destination] & " on " & [Date Leave] & " " & "has not been approved.
    > > Pls contact me at your earliest convince." & " " & "Thx Lewis",
    > > EditMessage:=False
    > > End If
    > >
    > > If Me.chkapproved = True Then
    > > DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    > > Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    > > DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    > > [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    > > [First and Last Name], , False
    > > DoCmd.PrintOut
    > > DoCmd.Close
    > > End If
    > >
    > > End Sub
    > >
    > > I have the two check boxes. Travel Approved and Revised. When a supervisor
    > > checks Travel Approved then It send an email to the traveler and to me.
    > > However If the box Revised is checked which is automatically done when they
    > > revise there trip. I would Like the Email to read a little differently. I
    > > do I add this step?
    > > I would like the email to the Traveler to be something around the lines of
    > > "Your revision to [Desination] on [Date Leave] has been approved.
    > >
    > > and the one sent to me to say something like [First and Last Name]'s trip
    > > to [Destination] on [Date Leave] has been revised and approved. Please fix
    > > changes made.
    > >
    > >
    > >
    > >
    > > Thanks
    > > Chey[/color][/color]
     
  5. rogereverest

    rogereverest
    Expand Collapse
    Guest

    Hy Chey,

    I notice from your code that you have more "If" stmts than "Endif"s. It
    helps if you indent your "If" stmts by a tab length and keep your "endif"s at
    the same tab as your "if"s. The probelem then becomes obvious. As Biz
    Enhancer said earlier nested ifs can be a brain buster but if you can lay
    your code out then it becomes easier. - eg:-

    If XXXX=YYYY Then
    If AAAA <> BBBB Then
    do something
    go somewhere
    endif
    If CCCC = DDDD Then
    do something
    endif
    do something
    endif

    Hope this helps


    "Chey" wrote:

    > so I did everything you said and when I went to go run it it says block end
    > without end if.
    >
    > Private Sub chkApproved_Click()
    > If Me.chkapproved = True Then
    > If Me.Revised = True Then
    > DoCmd.SendObject acSendNoObject, , , to:=, Subject:=[TA
    > Number], MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your
    > REVISED travel to " & [Destination] & " on " & [Date Leave] & " " & "has been
    > approved.", EditMessage:=True
    > Else
    > DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    > MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    > to " & [Destination] & " on " & [Date Leave] & " " & "has been approved.",
    > EditMessage:=False
    > End If
    > If Me.chkapproved = True Then
    > If Me.Revised = True Then
    > DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    > Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    > DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    > [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    > [First and Last Name], [First and Last Names] & "'s" & " " & "trip to" & " "
    > & [Destination] & " " & "REVISED has been approved please make the following
    > changes.", EditMessage:=False
    > DoCmd.PrintOut
    > DoCmd.Close
    > Else
    > DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    > Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    > DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    > [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    > [First and Last Name], [First and Last Names] & "'s" & " " & "trip to" & " "
    > & [Destination] & " " & "has been approved please book travel.", False
    > DoCmd.PrintOut
    > DoCmd.Close
    > End If
    > End Sub
    >
    > Thanks for your time.
    >
    > "Biz Enhancer" wrote:
    >[color=green]
    > > Hi Chey,
    > >
    > > If I am reading you right then a nested if statement should help.
    > >
    > > If Me.chkapproved = True Then
    > > If Me.chkrevised = True Then
    > > ' DoStuff where both chkboxes =true
    > > Else
    > > ' DoStuff where chkapproved=true and chkrevised=false
    > > End if
    > > Else
    > > ' DoStuff where chkapproved=false
    > > End if
    > >
    > > Nest as many conditions as you like, but be aware that it can give a bit of
    > > brain strain if to many are nested.
    > >
    > > Hope it helps.
    > >
    > > Regards,
    > > Nick.
    > >
    > > "Chey" wrote:
    > >[color=darkred]
    > > > I have this code
    > > > Private Sub chkApproved_Click()
    > > > If Me.chkapproved = True Then
    > > > DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    > > > MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    > > > to " & [Destination] & " on " & [Date Leave] & " " & "has been approved.",
    > > > EditMessage:=False
    > > > End If
    > > >
    > > > If Me.chknotapproved = True Then
    > > > DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    > > > MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    > > > to " & [Destination] & " on " & [Date Leave] & " " & "has not been approved.
    > > > Pls contact me at your earliest convince." & " " & "Thx Lewis",
    > > > EditMessage:=False
    > > > End If
    > > >
    > > > If Me.chkapproved = True Then
    > > > DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    > > > Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    > > > DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    > > > [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    > > > [First and Last Name], , False
    > > > DoCmd.PrintOut
    > > > DoCmd.Close
    > > > End If
    > > >
    > > > End Sub
    > > >
    > > > I have the two check boxes. Travel Approved and Revised. When a supervisor
    > > > checks Travel Approved then It send an email to the traveler and to me.
    > > > However If the box Revised is checked which is automatically done when they
    > > > revise there trip. I would Like the Email to read a little differently. I
    > > > do I add this step?
    > > > I would like the email to the Traveler to be something around the lines of
    > > > "Your revision to [Desination] on [Date Leave] has been approved.
    > > >
    > > > and the one sent to me to say something like [First and Last Name]'s trip
    > > > to [Destination] on [Date Leave] has been revised and approved. Please fix
    > > > changes made.
    > > >
    > > >
    > > >
    > > >
    > > > Thanks
    > > > Chey[/color][/color][/color]
     
  6. Biz Enhancer

    Biz Enhancer
    Expand Collapse
    Guest

    Hi Chey,

    You need to add another "End If" after the two "End If"s that are already
    present.

    For every "If" you must have an "End If", unless you use an "ElseIf"
    statement but we don't need to go there yet.

    hope it helps.

    Regards,
    Nick.

    "Chey" wrote:

    > so I did everything you said and when I went to go run it it says block end
    > without end if.
    >
    > Private Sub chkApproved_Click()
    > If Me.chkapproved = True Then
    > If Me.Revised = True Then
    > DoCmd.SendObject acSendNoObject, , , to:=, Subject:=[TA
    > Number], MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your
    > REVISED travel to " & [Destination] & " on " & [Date Leave] & " " & "has been
    > approved.", EditMessage:=True
    > Else
    > DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    > MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    > to " & [Destination] & " on " & [Date Leave] & " " & "has been approved.",
    > EditMessage:=False
    > End If
    > If Me.chkapproved = True Then
    > If Me.Revised = True Then
    > DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    > Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    > DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    > [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    > [First and Last Name], [First and Last Names] & "'s" & " " & "trip to" & " "
    > & [Destination] & " " & "REVISED has been approved please make the following
    > changes.", EditMessage:=False
    > DoCmd.PrintOut
    > DoCmd.Close
    > Else
    > DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    > Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    > DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    > [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    > [First and Last Name], [First and Last Names] & "'s" & " " & "trip to" & " "
    > & [Destination] & " " & "has been approved please book travel.", False
    > DoCmd.PrintOut
    > DoCmd.Close
    > End If
    > End Sub
    >
    > Thanks for your time.
    >
    > "Biz Enhancer" wrote:
    >[color=green]
    > > Hi Chey,
    > >
    > > If I am reading you right then a nested if statement should help.
    > >
    > > If Me.chkapproved = True Then
    > > If Me.chkrevised = True Then
    > > ' DoStuff where both chkboxes =true
    > > Else
    > > ' DoStuff where chkapproved=true and chkrevised=false
    > > End if
    > > Else
    > > ' DoStuff where chkapproved=false
    > > End if
    > >
    > > Nest as many conditions as you like, but be aware that it can give a bit of
    > > brain strain if to many are nested.
    > >
    > > Hope it helps.
    > >
    > > Regards,
    > > Nick.
    > >
    > > "Chey" wrote:
    > >[color=darkred]
    > > > I have this code
    > > > Private Sub chkApproved_Click()
    > > > If Me.chkapproved = True Then
    > > > DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    > > > MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    > > > to " & [Destination] & " on " & [Date Leave] & " " & "has been approved.",
    > > > EditMessage:=False
    > > > End If
    > > >
    > > > If Me.chknotapproved = True Then
    > > > DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    > > > MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    > > > to " & [Destination] & " on " & [Date Leave] & " " & "has not been approved.
    > > > Pls contact me at your earliest convince." & " " & "Thx Lewis",
    > > > EditMessage:=False
    > > > End If
    > > >
    > > > If Me.chkapproved = True Then
    > > > DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    > > > Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    > > > DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    > > > [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    > > > [First and Last Name], , False
    > > > DoCmd.PrintOut
    > > > DoCmd.Close
    > > > End If
    > > >
    > > > End Sub
    > > >
    > > > I have the two check boxes. Travel Approved and Revised. When a supervisor
    > > > checks Travel Approved then It send an email to the traveler and to me.
    > > > However If the box Revised is checked which is automatically done when they
    > > > revise there trip. I would Like the Email to read a little differently. I
    > > > do I add this step?
    > > > I would like the email to the Traveler to be something around the lines of
    > > > "Your revision to [Desination] on [Date Leave] has been approved.
    > > >
    > > > and the one sent to me to say something like [First and Last Name]'s trip
    > > > to [Destination] on [Date Leave] has been revised and approved. Please fix
    > > > changes made.
    > > >
    > > >
    > > >
    > > >
    > > > Thanks
    > > > Chey[/color][/color][/color]
     
  7. Chey

    Chey
    Expand Collapse
    Guest

    unfortunantly I still don't understand. Where am I missing the endif?
    I copied and pasted what he gave me.

    Thanks
    Chey

    "rogereverest" wrote:

    > Hy Chey,
    >
    > I notice from your code that you have more "If" stmts than "Endif"s. It
    > helps if you indent your "If" stmts by a tab length and keep your "endif"s at
    > the same tab as your "if"s. The probelem then becomes obvious. As Biz
    > Enhancer said earlier nested ifs can be a brain buster but if you can lay
    > your code out then it becomes easier. - eg:-
    >
    > If XXXX=YYYY Then
    > If AAAA <> BBBB Then
    > do something
    > go somewhere
    > endif
    > If CCCC = DDDD Then
    > do something
    > endif
    > do something
    > endif
    >
    > Hope this helps
    >
    >
    > "Chey" wrote:
    >
    > > so I did everything you said and when I went to go run it it says block end
    > > without end if.
    > >
    > > Private Sub chkApproved_Click()
    > > If Me.chkapproved = True Then
    > > If Me.Revised = True Then
    > > DoCmd.SendObject acSendNoObject, , , to:=, Subject:=[TA
    > > Number], MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your
    > > REVISED travel to " & [Destination] & " on " & [Date Leave] & " " & "has been
    > > approved.", EditMessage:=True
    > > Else
    > > DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    > > MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    > > to " & [Destination] & " on " & [Date Leave] & " " & "has been approved.",
    > > EditMessage:=False
    > > End If
    > > If Me.chkapproved = True Then
    > > If Me.Revised = True Then
    > > DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    > > Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    > > DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    > > [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    > > [First and Last Name], [First and Last Names] & "'s" & " " & "trip to" & " "
    > > & [Destination] & " " & "REVISED has been approved please make the following
    > > changes.", EditMessage:=False
    > > DoCmd.PrintOut
    > > DoCmd.Close
    > > Else
    > > DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    > > Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    > > DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    > > [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    > > [First and Last Name], [First and Last Names] & "'s" & " " & "trip to" & " "
    > > & [Destination] & " " & "has been approved please book travel.", False
    > > DoCmd.PrintOut
    > > DoCmd.Close
    > > End If
    > > End Sub
    > >
    > > Thanks for your time.
    > >
    > > "Biz Enhancer" wrote:
    > >[color=darkred]
    > > > Hi Chey,
    > > >
    > > > If I am reading you right then a nested if statement should help.
    > > >
    > > > If Me.chkapproved = True Then
    > > > If Me.chkrevised = True Then
    > > > ' DoStuff where both chkboxes =true
    > > > Else
    > > > ' DoStuff where chkapproved=true and chkrevised=false
    > > > End if
    > > > Else
    > > > ' DoStuff where chkapproved=false
    > > > End if
    > > >
    > > > Nest as many conditions as you like, but be aware that it can give a bit of
    > > > brain strain if to many are nested.
    > > >
    > > > Hope it helps.
    > > >
    > > > Regards,
    > > > Nick.
    > > >
    > > > "Chey" wrote:
    > > >
    > > > > I have this code
    > > > > Private Sub chkApproved_Click()
    > > > > If Me.chkapproved = True Then
    > > > > DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    > > > > MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    > > > > to " & [Destination] & " on " & [Date Leave] & " " & "has been approved.",
    > > > > EditMessage:=False
    > > > > End If
    > > > >
    > > > > If Me.chknotapproved = True Then
    > > > > DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    > > > > MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    > > > > to " & [Destination] & " on " & [Date Leave] & " " & "has not been approved.
    > > > > Pls contact me at your earliest convince." & " " & "Thx Lewis",
    > > > > EditMessage:=False
    > > > > End If
    > > > >
    > > > > If Me.chkapproved = True Then
    > > > > DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    > > > > Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    > > > > DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    > > > > [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    > > > > [First and Last Name], , False
    > > > > DoCmd.PrintOut
    > > > > DoCmd.Close
    > > > > End If
    > > > >
    > > > > End Sub
    > > > >
    > > > > I have the two check boxes. Travel Approved and Revised. When a supervisor
    > > > > checks Travel Approved then It send an email to the traveler and to me.
    > > > > However If the box Revised is checked which is automatically done when they
    > > > > revise there trip. I would Like the Email to read a little differently. I
    > > > > do I add this step?
    > > > > I would like the email to the Traveler to be something around the lines of
    > > > > "Your revision to [Desination] on [Date Leave] has been approved.
    > > > >
    > > > > and the one sent to me to say something like [First and Last Name]'s trip
    > > > > to [Destination] on [Date Leave] has been revised and approved. Please fix
    > > > > changes made.
    > > > >
    > > > >
    > > > >
    > > > >
    > > > > Thanks
    > > > > Chey[/color][/color][/color]
     
  8. Biz Enhancer

    Biz Enhancer
    Expand Collapse
    Guest

    Hi Chey,

    Try this.

    Private Sub chkApproved_Click()
    If Me.chkapproved = True Then
    If Me.Revised = True Then
    DoCmd.SendObject acSendNoObject, , , to:=, Subject:=[TA
    Number], MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your
    REVISED travel to " & [Destination] & " on " & [Date Leave] & " " & "has been
    approved.", EditMessage:=True
    Else
    DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    to " & [Destination] & " on " & [Date Leave] & " " & "has been approved.",
    EditMessage:=False
    End If
    End IF
    If Me.chkapproved = True Then
    If Me.Revised = True Then
    DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    [First and Last Name], [First and Last Names] & "'s" & " " & "trip to" & " "
    & [Destination] & " " & "REVISED has been approved please make the following
    changes.", EditMessage:=False
    DoCmd.PrintOut
    DoCmd.Close
    Else
    DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    [First and Last Name], [First and Last Names] & "'s" & " " & "trip to" & " "
    & [Destination] & " " & "has been approved please book travel.", False
    DoCmd.PrintOut
    DoCmd.Close
    End If
    End If
    End Sub


    "Chey" wrote:
    [color=blue]
    > unfortunantly I still don't understand. Where am I missing the endif?
    > I copied and pasted what he gave me.
    >
    > Thanks
    > Chey
    >
    > "rogereverest" wrote:
    >[color=green]
    > > Hy Chey,
    > >
    > > I notice from your code that you have more "If" stmts than "Endif"s. It
    > > helps if you indent your "If" stmts by a tab length and keep your "endif"s at
    > > the same tab as your "if"s. The probelem then becomes obvious. As Biz
    > > Enhancer said earlier nested ifs can be a brain buster but if you can lay
    > > your code out then it becomes easier. - eg:-
    > >
    > > If XXXX=YYYY Then
    > > If AAAA <> BBBB Then
    > > do something
    > > go somewhere
    > > endif
    > > If CCCC = DDDD Then
    > > do something
    > > endif
    > > do something
    > > endif
    > >
    > > Hope this helps
    > >
    > >
    > > "Chey" wrote:
    > >[color=darkred]
    > > > so I did everything you said and when I went to go run it it says block end
    > > > without end if.
    > > >
    > > > Private Sub chkApproved_Click()
    > > > If Me.chkapproved = True Then
    > > > If Me.Revised = True Then
    > > > DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA
    > > > Number], MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your
    > > > REVISED travel to " & [Destination] & " on " & [Date Leave] & " " & "has been
    > > > approved.", EditMessage:=True
    > > > Else
    > > > DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    > > > MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    > > > to " & [Destination] & " on " & [Date Leave] & " " & "has been approved.",
    > > > EditMessage:=False
    > > > End If
    > > > If Me.chkapproved = True Then
    > > > If Me.Revised = True Then
    > > > DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    > > > Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    > > > DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    > > > [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    > > > [First and Last Name], [First and Last Names] & "'s" & " " & "trip to" & " "
    > > > & [Destination] & " " & "REVISED has been approved please make the following
    > > > changes.", EditMessage:=False
    > > > DoCmd.PrintOut
    > > > DoCmd.Close
    > > > Else
    > > > DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    > > > Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    > > > DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    > > > [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    > > > [First and Last Name], [First and Last Names] & "'s" & " " & "trip to" & " "
    > > > & [Destination] & " " & "has been approved please book travel.", False
    > > > DoCmd.PrintOut
    > > > DoCmd.Close
    > > > End If
    > > > End Sub
    > > >
    > > > Thanks for your time.
    > > >
    > > > "Biz Enhancer" wrote:
    > > >
    > > > > Hi Chey,
    > > > >
    > > > > If I am reading you right then a nested if statement should help.
    > > > >
    > > > > If Me.chkapproved = True Then
    > > > > If Me.chkrevised = True Then
    > > > > ' DoStuff where both chkboxes =true
    > > > > Else
    > > > > ' DoStuff where chkapproved=true and chkrevised=false
    > > > > End if
    > > > > Else
    > > > > ' DoStuff where chkapproved=false
    > > > > End if
    > > > >
    > > > > Nest as many conditions as you like, but be aware that it can give a bit of
    > > > > brain strain if to many are nested.
    > > > >
    > > > > Hope it helps.
    > > > >
    > > > > Regards,
    > > > > Nick.
    > > > >
    > > > > "Chey" wrote:
    > > > >
    > > > > > I have this code
    > > > > > Private Sub chkApproved_Click()
    > > > > > If Me.chkapproved = True Then
    > > > > > DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    > > > > > MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    > > > > > to " & [Destination] & " on " & [Date Leave] & " " & "has been approved.",
    > > > > > EditMessage:=False
    > > > > > End If
    > > > > >
    > > > > > If Me.chknotapproved = True Then
    > > > > > DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    > > > > > MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    > > > > > to " & [Destination] & " on " & [Date Leave] & " " & "has not been approved.
    > > > > > Pls contact me at your earliest convince." & " " & "Thx Lewis",
    > > > > > EditMessage:=False
    > > > > > End If
    > > > > >
    > > > > > If Me.chkapproved = True Then
    > > > > > DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    > > > > > Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    > > > > > DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    > > > > > [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    > > > > > [First and Last Name], , False
    > > > > > DoCmd.PrintOut
    > > > > > DoCmd.Close
    > > > > > End If
    > > > > >
    > > > > > End Sub
    > > > > >
    > > > > > I have the two check boxes. Travel Approved and Revised. When a supervisor
    > > > > > checks Travel Approved then It send an email to the traveler and to me.
    > > > > > However If the box Revised is checked which is automatically done when they
    > > > > > revise there trip. I would Like the Email to read a little differently. I
    > > > > > do I add this step?
    > > > > > I would like the email to the Traveler to be something around the lines of
    > > > > > "Your revision to [Desination] on [Date Leave] has been approved.
    > > > > >
    > > > > > and the one sent to me to say something like [First and Last Name]'s trip
    > > > > > to [Destination] on [Date Leave] has been revised and approved. Please fix
    > > > > > changes made.
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > > Thanks
    > > > > > Chey[/color][/color][/color]
     
  9. Chey

    Chey
    Expand Collapse
    Guest

    Thanks I got it to work.
    I wasn't thinking when I did that last post

    "Biz Enhancer" wrote:

    > Hi Chey,
    >
    > You need to add another "End If" after the two "End If"s that are already
    > present.
    >
    > For every "If" you must have an "End If", unless you use an "ElseIf"
    > statement but we don't need to go there yet.
    >
    > hope it helps.
    >
    > Regards,
    > Nick.
    >
    > "Chey" wrote:
    >
    > > so I did everything you said and when I went to go run it it says block end
    > > without end if.
    > >
    > > Private Sub chkApproved_Click()
    > > If Me.chkapproved = True Then
    > > If Me.Revised = True Then
    > > DoCmd.SendObject acSendNoObject, , , to:=, Subject:=[TA
    > > Number], MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your
    > > REVISED travel to " & [Destination] & " on " & [Date Leave] & " " & "has been
    > > approved.", EditMessage:=True
    > > Else
    > > DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    > > MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    > > to " & [Destination] & " on " & [Date Leave] & " " & "has been approved.",
    > > EditMessage:=False
    > > End If
    > > If Me.chkapproved = True Then
    > > If Me.Revised = True Then
    > > DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    > > Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    > > DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    > > [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    > > [First and Last Name], [First and Last Names] & "'s" & " " & "trip to" & " "
    > > & [Destination] & " " & "REVISED has been approved please make the following
    > > changes.", EditMessage:=False
    > > DoCmd.PrintOut
    > > DoCmd.Close
    > > Else
    > > DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    > > Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    > > DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    > > [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    > > [First and Last Name], [First and Last Names] & "'s" & " " & "trip to" & " "
    > > & [Destination] & " " & "has been approved please book travel.", False
    > > DoCmd.PrintOut
    > > DoCmd.Close
    > > End If
    > > End Sub
    > >
    > > Thanks for your time.
    > >
    > > "Biz Enhancer" wrote:
    > >[color=darkred]
    > > > Hi Chey,
    > > >
    > > > If I am reading you right then a nested if statement should help.
    > > >
    > > > If Me.chkapproved = True Then
    > > > If Me.chkrevised = True Then
    > > > ' DoStuff where both chkboxes =true
    > > > Else
    > > > ' DoStuff where chkapproved=true and chkrevised=false
    > > > End if
    > > > Else
    > > > ' DoStuff where chkapproved=false
    > > > End if
    > > >
    > > > Nest as many conditions as you like, but be aware that it can give a bit of
    > > > brain strain if to many are nested.
    > > >
    > > > Hope it helps.
    > > >
    > > > Regards,
    > > > Nick.
    > > >
    > > > "Chey" wrote:
    > > >
    > > > > I have this code
    > > > > Private Sub chkApproved_Click()
    > > > > If Me.chkapproved = True Then
    > > > > DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    > > > > MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    > > > > to " & [Destination] & " on " & [Date Leave] & " " & "has been approved.",
    > > > > EditMessage:=False
    > > > > End If
    > > > >
    > > > > If Me.chknotapproved = True Then
    > > > > DoCmd.SendObject acSendNoObject, , , to:=[Email], Subject:=[TA Number],
    > > > > MessageText:="Dear " & [First and Last Name] & ", " & vbCrLf & "Your travel
    > > > > to " & [Destination] & " on " & [Date Leave] & " " & "has not been approved.
    > > > > Pls contact me at your earliest convince." & " " & "Thx Lewis",
    > > > > EditMessage:=False
    > > > > End If
    > > > >
    > > > > If Me.chkapproved = True Then
    > > > > DoCmd.OpenReport "Travel Request 0 Layover", acViewPreview, , "[TA
    > > > > Numbers.TA Number]=[Forms]![Appoved]![TA Number]"
    > > > > DoCmd.SendObject acSendReport, "Travel Request 0 Layover", acFormatSNP,
    > > > > [Request Given to Email], , , "Travel Approved" & " " & [TA Number] & " " &
    > > > > [First and Last Name], , False
    > > > > DoCmd.PrintOut
    > > > > DoCmd.Close
    > > > > End If
    > > > >
    > > > > End Sub
    > > > >
    > > > > I have the two check boxes. Travel Approved and Revised. When a supervisor
    > > > > checks Travel Approved then It send an email to the traveler and to me.
    > > > > However If the box Revised is checked which is automatically done when they
    > > > > revise there trip. I would Like the Email to read a little differently. I
    > > > > do I add this step?
    > > > > I would like the email to the Traveler to be something around the lines of
    > > > > "Your revision to [Desination] on [Date Leave] has been approved.
    > > > >
    > > > > and the one sent to me to say something like [First and Last Name]'s trip
    > > > > to [Destination] on [Date Leave] has been revised and approved. Please fix
    > > > > changes made.
    > > > >
    > > > >
    > > > >
    > > > >
    > > > > Thanks
    > > > > Chey[/color][/color][/color]
     

Share This Page