I use the code below to populate a DataGrid. It does everything it should, it's just that I have a formatting problem.
grTimeMon, grTimeTue etc are DateTime and hold the time of a class. If, for example, a group has two classes a week of 1:30 on Tue at 16:00 and Fri at 19:30, then grTimeTue will hold 16:00 and grTimeFri will hold 19:30. All the others will hold zero (formatted as time).
I want to know if there is some way to display a space instead of "00:00" when the value is zero.
grTimeMon, grTimeTue etc are DateTime and hold the time of a class. If, for example, a group has two classes a week of 1:30 on Tue at 16:00 and Fri at 19:30, then grTimeTue will hold 16:00 and grTimeFri will hold 19:30. All the others will hold zero (formatted as time).
I want to know if there is some way to display a space instead of "00:00" when the value is zero.
vb Code:
Private Sub FillDGrid() Dim f As Integer Dim sSQL As String sSQL = "SELECT grName AS [Group] , grHours AS [Length] ,grTimeMon AS Mon, grTimeTue AS Tue, grTimeWed AS Wed, " sSQL = sSQL & " grTimeThu AS Thu, grTimeFri AS Fri, grTimeSat AS Sat, grTimeSun AS Sun " sSQL = sSQL & " FROM tblGroup ORDER BY grName" ShowData (sSQL) dgGroup.Columns(0).Width = 1200 For f = 1 To 8 dgGroup.Columns(f).Width = 800 dgGroup.Columns(f).NumberFormat = "h:mm" Next f dgGroup.Columns(1).NumberFormat = "hh:mm" End Sub Private Sub ShowData(ByVal sSQL As String) Set conn = New ADODB.Connection conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & App.Path & "\Student.mdb;Persist Security Info=False" conn.Open Set RecSet = New ADODB.Recordset RecSet.CursorLocation = adUseClient RecSet.Open sSQL, cn, adOpenKeyset, adLockPessimistic, adCmdText Set dgGroup.DataSource = RecSet dgGroup.Refresh End Sub