John-
I am using this in vb:
On Error GoTo ErrHandle
Dim strRpt As String
Dim strPrefix As String
Dim strEmailAddress As String
Dim strSubject As String
strRpt = IIf(IsNull(OptionDate),"rptHotelBookingAskOption","rptHotelBookingExtendOption")
strPrefix = IIf(IsNull(OptionDate),"Asking for Option for group: ","Asking for Extending the Option for group: ")
strEmailAddress = ELookup("HotelContactEmail", "tblHotelContact", "HotelID=" & Me.HotelID, "RecentContact ASC")
strSubject = strPrefix & "-" & IIf(IsNull(HotelBookingCode), Me.Parent.GroupCode & "-" & HotelBookingID, Me.Parent.GroupCode & "-" & _
HotelBookingID & " (Reference: " & HotelBookingCode & ")") & " From " & ELookup("CompanyEnglishName", "tblCompany", "CompanyID=" & 1)
If vbYes = MsgBox("Click Yes to send. " & _
" Click No to edit.", vbQuestion + vbYesNo + vbDefaultButton2) Then
DoCmd.OpenReport strRpt, acViewPreview, , "HotelBookingID = " & Me.HotelBookingID, acHidden
SendReportHTML strRpt, strEmailAddress, strSubject, "Send", ""
DoCmd.Close acReport, strRpt, acSaveNo
Else
DoCmd.OpenReport strRpt, acViewPreview, , "HotelBookingID = " & Me.HotelBookingID, acHidden
SendReportHTML strRpt, strEmailAddress, strSubject, "Display", ""
DoCmd.Close acReport, strRpt, acSaveNo
End If
ErrExit:
Exit Sub
ErrHandle:
Resume ErrExit
Dim strRpt As String
Dim strPrefix As String
Dim strEmailAddress As String
Dim strSubject As String
strRpt = IIf(IsNull(OptionDate),"rptHotelBookingAskOption","rptHotelBookingExtendOption")
strPrefix = IIf(IsNull(OptionDate),"Asking for Option for group: ","Asking for Extending the Option for group: ")
strEmailAddress = ELookup("HotelContactEmail", "tblHotelContact", "HotelID=" & Me.HotelID, "RecentContact ASC")
strSubject = strPrefix & "-" & IIf(IsNull(HotelBookingCode), Me.Parent.GroupCode & "-" & HotelBookingID, Me.Parent.GroupCode & "-" & _
HotelBookingID & " (Reference: " & HotelBookingCode & ")") & " From " & ELookup("CompanyEnglishName", "tblCompany", "CompanyID=" & 1)
If vbYes = MsgBox("Click Yes to send. " & _
" Click No to edit.", vbQuestion + vbYesNo + vbDefaultButton2) Then
DoCmd.OpenReport strRpt, acViewPreview, , "HotelBookingID = " & Me.HotelBookingID, acHidden
SendReportHTML strRpt, strEmailAddress, strSubject, "Send", ""
DoCmd.Close acReport, strRpt, acSaveNo
Else
DoCmd.OpenReport strRpt, acViewPreview, , "HotelBookingID = " & Me.HotelBookingID, acHidden
SendReportHTML strRpt, strEmailAddress, strSubject, "Display", ""
DoCmd.Close acReport, strRpt, acSaveNo
End If
ErrExit:
Exit Sub
ErrHandle:
Resume ErrExit
Best Regards,
Kevin
Date: 2015-12-31 00:02Subject: Re: [MS_AccessPros] If IsNull(OptionDate)Kevin-
Where are you using this - in a query?Only obvious thing is to put brackets around the field name:IIf(IsNull([OptionDate]),"rptHotelBookingAskOption","rptHotelBookingExtendOption")John Viescas, AuthorMicrosoft Access 2010 Inside OutMicrosoft Access 2007 Inside OutMicrosoft Access 2003 Inside OutBuilding Microsoft Access ApplicationsSQL Queries for Mere Mortals(Paris, France)
On Dec 30, 2015, at 4:50 PM, 'zhaoliqingoffice@163.com' zhaoliqingoffice@163.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:Dear All,Please check this code: IIf(IsNull(OptionDate),"rptHotelBookingAskOption","rptHotelBookingExtendOption")My problem is: if OptionDate is null, the the result won't be "rptHotelBookingAskOption". What's wrong with this code? Thanks.Best Regards,Kevin
__._,_.___
Posted by: "zhaoliqingoffice@163.com" <zhaoliqingoffice@163.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (4) |
.
__,_._,___
Tidak ada komentar:
Posting Komentar