Hi,

I have a requirement that when a user click on a record in the datagrid (the record holds Emp_id and his/her project allocation date and release date), then the dates from allocation date to release date in monthview should display bold.

I have written the code but i dont know how to call MonthView1_GetDayBold procedures.

Here is the 2 set of code

Private Sub DataGrid1_Click()
Dim MyConn As ADODB.Connection
Dim MyRecSet1 As New ADODB.Recordset
Set MyConn = New ADODB.Connection
MyConn.ConnectionString = "Provider=SQLOLEDB;Data Source=DIVAKAR-PC\LOCALHOST;Initial Catalog=RMG;User Id=RMG;Password=Thinksoft"
MyConn.Open
    
    On Error Resume Next
    If ResAvail.DataGrid1.SelBookmarks.Count = 0 Then
    Exit Sub
    End If
    
    Emp_Id = ResAvail.DataGrid1.Columns(0).Value
    Allocated_On = ResAvail.DataGrid1.Columns(9).Value
    Release_Date = ResAvail.DataGrid1.Columns(10).Value
    
MonthView1_GetDayBold CDate(Date), 1, True
    
End Sub

Sub MonthView1_GetDayBold(ByVal StartDate As Date, ByVal Count As Integer, State() As Boolean)
    d = StartDate
    For i = 0 To Count - 1
        If d >= Allocated_On And d <= Release_Date Then
            State(i) = True          ' Mark all blocked days.
        End If
        d = d + 1
    Next
End Sub

As this is a pretty urgent, appreciate if you help me soon

Recommended Answers

All 3 Replies

Hi,

After a long struggle, i found the solution as to how to call the procedure. Below is the updated code

Private Sub DataGrid1_Click()
Dim State() As Boolean
Dim StartDate As Date
MonthView1_GetDayBold StartDate, 1, State()
End Sub

Sub MonthView1_GetDayBold(ByVal StartDate As Date, ByVal Count As Integer, State() As Boolean)
Dim Allocated_On As Date
Dim Release_date As Date
Dim d As Date
Dim MyConn As ADODB.Connection
Dim MyRecSet1 As New ADODB.Recordset
Set MyConn = New ADODB.Connection
MyConn.ConnectionString = "Provider=SQLOLEDB;Data Source=DIVAKAR-PC\LOCALHOST;Initial Catalog=RMG;User Id=RMG;Password=Thinksoft"
MyConn.Open
    
    On Error Resume Next
    If ResAvail.DataGrid1.SelBookmarks.Count = 0 Then
    Exit Sub
    End If

    
    Emp_Id = ResAvail.DataGrid1.Columns(0).Value
    Allocated_On = ResAvail.DataGrid1.Columns(9).Value
    Release_date = ResAvail.DataGrid1.Columns(10).Value
    
    d = StartDate
    For i = 0 To Count - 1
        If d >= Allocated_On And d <= Release_date Then
            State(i) = True          ' Bold all blocked days.
        End If
        
        d = d + 1
    Next
    
End Sub

Now the problem is, While passing the Start date and Count it should be as below

Start date = The start date of the Monthview i.e if last week of the previous month displaying in the current monthview window, then start date would 1st day of the last week of the previous month

Count = The count of visible dates in a currnet monthview window i.e if last week of the previous month and 1st week of next month falling in the current monthview window then the count would current month days + Previus month last week visible days + Next month 1st week visible days in the current monthview window

Now i want to know how to get the above to values so that i can pass it over to the procedure

As the requirement now changed, am closing this thread and open a new thread for the problem am facing with new requirement

Divakar, please mark this as solved so it can be closed properly, thanks.:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.