I am wanting to modify the text formatting of a column when it is exported from my Access database so that the text is BOLD and in ITALICS.
The column will not change in terms of its position in my Excel spreadsheet. It will always be Column D.
The code I am using to spit out my Access data into Excel is as follows:
How would I add a little extra to the end, in order to make TblTcDel.[REG] appear with Bold and italics? Ideally I would like the column header to not be touched so maybe doing something like D2 through to the end might be the best solution?
I look forward to hearing you clever Access guys' opinions
The column will not change in terms of its position in my Excel spreadsheet. It will always be Column D.
The code I am using to spit out my Access data into Excel is as follows:
Code:
Me.All_Fleet_Chk.Value = True
Dim ctl As Control
Dim sFilter As String
Dim sContName As String
sFilter = ""
sFilter = "AND TblTcDel.[ATA2DIGIT] IN (0"
For Each ctl In Controls
If ctl.Tag = "ATA" Then
sContName = Right(ctl.Name, 2)
'Debug.Print sContName
'Once you have this working listing each control now interrogate the value
If ctl.Value = True Then
sFilter = sFilter & "," & sContName
End If
End If
Next ctl
sFilter = sFilter & ")"
Debug.Print sFilter
Dim dbsCurrent As Database
Dim SQL_Name As QueryDef
Dim SQL_Output As String
Dim dStart As String
Dim dEnd As String
Set dbsCurrent = CurrentDb
Set SQL_Name = dbsCurrent.QueryDefs("qry_report_criteria")
dStart = "#" & Format([Forms]![FrmRptCriteria]![Beg_date_txt], "mm/dd/yyyy") & "#"
dEnd = "#" & Format([Forms]![FrmRptCriteria]![End_Date_txt], "mm/dd/yyyy") & "#"
SQL_Output = "SELECT TblTcDel.ID, TblTcDel.Date, tblfltcodes.FlightCode, TblTcDel.[FLIGHT NO], TblTcDel.STN, TblTcDel.REG, TblTcDel.ATA, TblTcDel.ATASecondary, TblTcDel.[REASON FOR DELAY], TblTcDel.[DELAY HRS], TblTcDel.[DELAY MINS], TblTcDel.AOG, TblTcDel.[Part Number], TblTcDel.[Serial Number], TblTcDel.[Rectification Information], TblTcDel.DelayTotalMins, tblactype.actypeid, tblactype.Type, tblactype.Manufacturer, tblflighttype.flighttypeid, TblTcDel.[Severity Index], TblTcDel.[Charter Flight] " & _
"FROM tblactype INNER JOIN (tblflighttype INNER JOIN (TblAcrft INNER JOIN ((TblTcDel INNER JOIN TblAirports ON TblTcDel.STN = TblAirports.STN) INNER JOIN tblfltcodes ON TblTcDel.Flight_Code = tblfltcodes.fltcodeid) ON TblAcrft.Reg = TblTcDel.REG) ON tblflighttype.flighttypeid = tblfltcodes.LinktoFlightType) ON tblactype.actypeid = TblAcrft.ModelLink " & _
"WHERE ((TblTcDel.Date)>=" & dStart & " And (TblTcDel.Date)<=" & dEnd & " AND ((TblTcDel.DelayTotalMins)>=[forms]![FrmRptCriteria]![Delay_Time])) "
If Me.All_Fleet_Chk = True Then
If Me.All_Type_Chk = True Then ' All Fleets all Flights
sWhere = ""
Else ' All Fleets limited to Flight type as chosen
sWhere = " AND ((tblflighttype.flighttypeid)=[forms]![FrmRptCriteria]![Type_cbo]) "
End If
Else
If Me.NewACRFTchk = True Then
If Me.All_Type_Chk = True Then
sWhere = " AND ((TblAcrft.New)=-1) "
Else
sWhere = " AND ((TblAcrft.New)=-1) AND ((tblflighttype.flighttypeid)=[forms]![FrmRptCriteria]![Type_cbo]) "
End If
Else
If Me.All_Type_Chk = True Then ' Selected fleet all flights
If Me.ETOPSChk = True Then
sWhere = " AND ((TblAcrft.ETOPS)=-1) "
Else
If Not IsNull(Me.REGFilter) Then
sWhere = " AND TblTcDel.[REG] = [Forms]![FrmRptCriteria]![REGFilter] "
Else
sWhere = " AND ((tblactype.actypeid)=[Forms]![FrmRptCriteria]![Model_cbo]) "
End If
End If
Else ' Selected Fleet Selected Flight Type
If Me.ETOPSChk = True Then
sWhere = " AND ((TblAcrft.ETOPS)=-1) AND ((tblflighttype.flighttypeid)=[forms]![FrmRptCriteria]![Type_cbo]) "
Else
If Not IsNull(Me.REGFilter) Then
sWhere = " AND TblTcDel.[REG] = [Forms]![FrmRptCriteria]![REGFilter] AND ((tblflighttype.flighttypeid)=[forms]![FrmRptCriteria]![Type_cbo]) "
Else
sWhere = " AND ((tblactype.actypeid)=[Forms]![FrmRptCriteria]![Model_cbo]) AND ((tblflighttype.flighttypeid)=[forms]![FrmRptCriteria]![Type_cbo]) "
End If
End If
End If
End If
End If
If Not IsNull(Me.EventTypeFilter) Then
sWhere = sWhere & " AND ((TblTcDel.[Event Type])=[Forms]![FrmRptCriteria]![EventTypeFilter])"
End If
If Me.SummerChk.Value = True Then
sWhere = sWhere & " AND ((TblTcDel.[Season])= 'Summer') "
End If
If Me.WinterChk.Value = True Then
sWhere = sWhere & " AND ((TblTcDel.[Season])= 'Winter') "
End If
If Me.Code41Chk.Value = True Then
sWhere = sWhere & " AND ((TblTcDel.[Delay Type])= '41') "
End If
If Me.Code46Chk.Value = True Then
sWhere = sWhere & " AND ((TblTcDel.[Delay Type])= '46') "
End If
If Me.ETOPSSectorChk.Value = True Then
sWhere = " AND ((TblTcDel.[ETOPS Sector])=-1) "
End If
If Me.CharterFlightChk.Value = True Then
sWhere = sWhere & " AND ((TblTcDel.[Charter Flight])=-1) "
End If
If Not IsNull(Me.SeverityIndexLower) And IsNull(Me.SeverityIndexUpper) Then
sWhere = sWhere & " AND ((TblTcDel.[Severity Index])>=[Forms]![FrmRptCriteria]![SeverityIndexLower])"
End If
If Not IsNull(Me.SeverityIndexLower) And Not IsNull(Me.SeverityIndexUpper) Then
sWhere = sWhere & " AND ((TblTcDel.[Severity Index])>=[Forms]![FrmRptCriteria]![SeverityIndexLower]) AND ((TblTcDel.[Severity Index])<=[Forms]![FrmRptCriteria]![SeverityIndexUpper])"
End If
If IsNull(Me.SeverityIndexLower) And Not IsNull(Me.SeverityIndexUpper) Then
sWhere = sWhere & " AND ((TblTcDel.[Severity Index])<=[Forms]![FrmRptCriteria]![SeverityIndexUpper])"
End If
If Me.SeverityFilter = "High" Then
sWhere = sWhere & " AND ((TblTcDel.[Severity Index])>=0.75)"
End If
If Me.SeverityFilter = "Medium" Then
sWhere = sWhere & " AND ((TblTcDel.[Severity Index])>=0.27) AND ((TblTcDel.[Severity Index])<0.75)"
End If
If Me.SeverityFilter = "Low" Then
sWhere = sWhere & " AND ((TblTcDel.[Severity Index])<0.27)"
End If
sWhere = sWhere & " AND ((tblactype.actypeid)=2) "
Debug.Print SQL_Output & sWhere & sFilter
SQL_Name.SQL = SQL_Output & sWhere & sFilter
DoCmd.Echo False
DoCmd.OpenQuery "Top10Issues737300Cut"
DoCmd.RunCommand acCmdOutputToExcel
DoCmd.Close acQuery, "Top10Issues737300Cut"
DoCmd.Echo True
Set dbsCurrent = Nothing
Set SQL_Name = Nothing
How would I add a little extra to the end, in order to make TblTcDel.[REG] appear with Bold and italics? Ideally I would like the column header to not be touched so maybe doing something like D2 through to the end might be the best solution?
I look forward to hearing you clever Access guys' opinions