Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

[TUT] VB6 MSAccess Sample using ADO (UPDATED V3 20100216) now with ADD and DataReport

Re: [TUT] VB6 MSAccess Sample using ADO (UPDATED V3 20100216) now with ADD and DataRe

yes sir, aware naman ako sa local ip at ung ip na given nung provider na ngchachange.., ang iniisip ko kasi is kumuha ng static ip sa isp na inooffer naman nila..,

so dapat ko munang gwin is mag setup ng webserver?
 
Re: [TUT] VB6 MSAccess Sample using ADO (UPDATED V3 20100216) now with ADD and DataRe

yes sir, aware naman ako sa local ip at ung ip na given nung provider na ngchachange.., ang iniisip ko kasi is kumuha ng static ip sa isp na inooffer naman nila..,

so dapat ko munang gwin is mag setup ng webserver?


yup:)
 
Re: [TUT] VB6 MSAccess Sample using ADO (UPDATED V3 20100216) now with ADD and DataRe


sorry if madameng tanong, interested lang ako dito pero mejo broad kasi kya di ko lam san mg start., while reading some post sa internet.,
may isa na pwde ka magself host using XAMPP..,

ask ko lang sir if pwede ito para ung program ko makaconnect sa database?
 
Re: [TUT] VB6 MSAccess Sample using ADO (UPDATED V3 20100216

thanks po dito
 
Re: [TUT] VB6 MSAccess Sample using ADO

thaNKS dito sir ..
 
Re: [TUT] VB6 MSAccess Sample using ADO

:thanks: po dito :salute:
 
Last edited:
Re: [TUT] VB6 MSAccess Sample using ADO

CALENDAR SYSTEM RETRIEVING DATA FUNCTION FROM ACCESS DB
MSFLEXGRID GAMIT KO SA CALENDAR VIEW

Nid po ksi dito e display lahat ng rs.fields(2).value sa ilalim ng cell na same date sa rs.fields(1).value
Wla nman pong error sa given code ko pro panu di nag display sa grid lahat ng data within all value of certain field?

nka wend namn at meron ng rs.movenext pro ang na display lng ay yung Last field lng ng rs.fields(1).value at rs.fields(2).value dun sa calendar grid.
Pa help nman bka may suggestion kyo.

nka attach jan ang sourcecode sana mka tulong kyo. thanks sa lahat
 

Attachments

  • Calendar.zip
    16.6 KB · Views: 3
Re: [TUT] VB6 MSAccess Sample using ADO

CALENDAR SYSTEM RETRIEVING DATA FUNCTION FROM ACCESS DB
MSFLEXGRID GAMIT KO SA CALENDAR VIEW

Nid po ksi dito e display lahat ng rs.fields(2).value sa ilalim ng cell na same date sa rs.fields(1).value
Wla nman pong error sa given code ko pro panu di nag display sa grid lahat ng data within all value of certain field?

nka wend namn at meron ng rs.movenext pro ang na display lng ay yung Last field lng ng rs.fields(1).value at rs.fields(2).value dun sa calendar grid.
Pa help nman bka may suggestion kyo.

nka attach jan ang sourcecode sana mka tulong kyo. thanks sa lahat

pakita mo nalang yung code mo
 
Re: [TUT] VB6 MSAccess Sample using ADO

pakita mo nalang yung code mo

Code:
Public Function Display(grd As MSFlexGrid)
    If Rs.State = 1 Then Rs.Close
    SQL = "SELECT * FROM Tbl_Cal"
    Rs.Open SQL, Con
    

    Rs.MoveFirst
    While Not Rs.EOF
    
    
    Dim theDate As Long
    Dim m_Date As Long
    Dim lastDate As Long
    Dim firstDate As Long
    Dim firstCol As Long
    Dim wRows As Long
    Dim wRow As Long
    Dim wCol As Long
    Dim wDate As Long
    Dim rDate As Long

    [COLOR=#008000]'   Date = NOW[/COLOR]
    m_Date = Date
    theDate = m_Date
    
    [COLOR=#008000]'   DECLARE FIRST DATE OF THE MONTH[/COLOR]
    firstDate = DateSerial(Year(theDate), Month(theDate), 1)
    
    [COLOR=#008000]'   DECLARE LAST DATE OF THE MONTH[/COLOR]
    lastDate = DateSerial(Year(theDate), Month(theDate) + 1, 1) - 1
    
[COLOR=#008000]   ' DECLARE THE FIRST COLUMN OF GRID[/COLOR]
    firstCol = Weekday(firstDate, vbUseSystemDayOfWeek) - 1

[COLOR=#008000]   ' DECLARE THE NUMBER OF ROWS[/COLOR]
    wRows = DateDiff("ww", firstDate, lastDate, vbUseSystemDayOfWeek) + 1
    
    
        Form1.lblDate.Caption = Format(Date, "mmmm - yyyy")
       
    With grd
        
        .Appearance = flexFlat
        .ScrollBars = flexScrollBarNone
        
        [COLOR=#008000]' Just some color settings[/COLOR]
        .GridColor = vbWhite
        .BackColor = .GridColor
        
        [COLOR=#008000]' No highlighting[/COLOR]
        .HighLight = flexHighlightNever
        .FocusRect = flexFocusLight
        
        ' Enable texts to span multiple lines
        .WordWrap = True
        
        [COLOR=#008000]' Number of days in a week [/COLOR]
        .Cols = 7
        
        [COLOR=#008000]' For the date header[/COLOR]
        .Rows = wRows * 5
        .Clear
        
        wRow = 0
        wCol = firstCol - 1
    
        For wDate = firstDate To lastDate
        
            wCol = wCol + 1
                If wCol > 6 Then
                wRow = wRow + 2
                wCol = 0
            End If
               
            
            .Col = wCol
            .Row = wRow
            
            [COLOR=#008000]' header design
            ' Display number of days[/COLOR]
            .TextMatrix(wRow, wCol) = Format(wDate, "d")

            [COLOR=#008000]' Alingment of number of days[/COLOR]
            .CellAlignment = flexAlignLeftCenter
         
            If Weekday(wDate, vbMonday) > 5 Then
                .CellBackColor = &HFFC0C0   [COLOR=#008000]'   weekend     header cell color[/COLOR]
            Else
                .CellBackColor = &HFFFFC0[COLOR=#008000]   '   weekdays    header cell color[/COLOR]
            End If
            
            [COLOR=#008000]'   Current date Header Color[/COLOR]
            If wDate = Date Then .CellBackColor = &H8000000D
            
            
            .Row = wRow + 1 '   adjust to the Cell below the header
            [COLOR=#008000]' Cell below the header design[/COLOR]
            .CellAlignment = flexAlignCenterCenter
            .CellFontBold = True
       
            If Weekday(wDate, vbMonday) > 5 Then
            
                 [COLOR=#008000]'   weekend cell color[/COLOR]
                 .CellBackColor = vbWhite
                 
            Else
            
                 [COLOR=#008000]'   weekday cell color[/COLOR]
                 .CellBackColor = vbWhite
                 
                 [COLOR=#008000]' this is where you can retrieve data from db and display it to grid[/COLOR]
                 If wDate = DateValue(Rs.Fields(1).Value) Then .Text = Rs.Fields(2).Value
                 
            End If
        
            [COLOR=#008000]'   Current date cell color[/COLOR]
            If wDate = Date Then .CellBackColor = &H8000000F
            
            Next wDate
            
           .FixedRows = 0
           .FixedCols = 0
           .Col = firstCol
           .Row = 1
    
    End With
Rs.MoveNext
Wend
End Function

nka attach din po ay ang image kpag i run na ung program thanks po
 

Attachments

  • Untitled.png
    Untitled.png
    165.8 KB · Views: 9
Last edited:
Re: [TUT] VB6 MSAccess Sample using ADO

Code:
Public Function Display(grd As MSFlexGrid)
    If Rs.State = 1 Then Rs.Close
    SQL = "SELECT * FROM Tbl_Cal"
    Rs.Open SQL, Con
    

    Rs.MoveFirst
    While Not Rs.EOF
    
    
    Dim theDate As Long
    Dim m_Date As Long
    Dim lastDate As Long
    Dim firstDate As Long
    Dim firstCol As Long
    Dim wRows As Long
    Dim wRow As Long
    Dim wCol As Long
    Dim wDate As Long
    Dim rDate As Long

    [COLOR=#008000]'   Date = NOW[/COLOR]
    m_Date = Date
    theDate = m_Date
    
    [COLOR=#008000]'   DECLARE FIRST DATE OF THE MONTH[/COLOR]
    firstDate = DateSerial(Year(theDate), Month(theDate), 1)
    
    [COLOR=#008000]'   DECLARE LAST DATE OF THE MONTH[/COLOR]
    lastDate = DateSerial(Year(theDate), Month(theDate) + 1, 1) - 1
    
[COLOR=#008000]   ' DECLARE THE FIRST COLUMN OF GRID[/COLOR]
    firstCol = Weekday(firstDate, vbUseSystemDayOfWeek) - 1

[COLOR=#008000]   ' DECLARE THE NUMBER OF ROWS[/COLOR]
    wRows = DateDiff("ww", firstDate, lastDate, vbUseSystemDayOfWeek) + 1
    
    
        Form1.lblDate.Caption = Format(Date, "mmmm - yyyy")
       
    With grd
        
        .Appearance = flexFlat
        .ScrollBars = flexScrollBarNone
        
        [COLOR=#008000]' Just some color settings[/COLOR]
        .GridColor = vbWhite
        .BackColor = .GridColor
        
        [COLOR=#008000]' No highlighting[/COLOR]
        .HighLight = flexHighlightNever
        .FocusRect = flexFocusLight
        
        ' Enable texts to span multiple lines
        .WordWrap = True
        
        [COLOR=#008000]' Number of days in a week [/COLOR]
        .Cols = 7
        
        [COLOR=#008000]' For the date header[/COLOR]
        .Rows = wRows * 5
        .Clear
        
        wRow = 0
        wCol = firstCol - 1
    
        For wDate = firstDate To lastDate
        
            wCol = wCol + 1
                If wCol > 6 Then
                wRow = wRow + 2
                wCol = 0
            End If
               
            
            .Col = wCol
            .Row = wRow
            
            [COLOR=#008000]' header design
            ' Display number of days[/COLOR]
            .TextMatrix(wRow, wCol) = Format(wDate, "d")

            [COLOR=#008000]' Alingment of number of days[/COLOR]
            .CellAlignment = flexAlignLeftCenter
         
            If Weekday(wDate, vbMonday) > 5 Then
                .CellBackColor = &HFFC0C0   [COLOR=#008000]'   weekend     header cell color[/COLOR]
            Else
                .CellBackColor = &HFFFFC0[COLOR=#008000]   '   weekdays    header cell color[/COLOR]
            End If
            
            [COLOR=#008000]'   Current date Header Color[/COLOR]
            If wDate = Date Then .CellBackColor = &H8000000D
            
            
            .Row = wRow + 1 '   adjust to the Cell below the header
            [COLOR=#008000]' Cell below the header design[/COLOR]
            .CellAlignment = flexAlignCenterCenter
            .CellFontBold = True
       
            If Weekday(wDate, vbMonday) > 5 Then
            
                 [COLOR=#008000]'   weekend cell color[/COLOR]
                 .CellBackColor = vbWhite
                 
            Else
            
                 [COLOR=#008000]'   weekday cell color[/COLOR]
                 .CellBackColor = vbWhite
                 
                 [COLOR=#008000]' this is where you can retrieve data from db and display it to grid[/COLOR]
                 If wDate = DateValue(Rs.Fields(1).Value) Then .Text = Rs.Fields(2).Value
                 
            End If
        
            [COLOR=#008000]'   Current date cell color[/COLOR]
            If wDate = Date Then .CellBackColor = &H8000000F
            
            Next wDate
            
           .FixedRows = 0
           .FixedCols = 0
           .Col = firstCol
           .Row = 1
    
    End With
Rs.MoveNext
Wend
End Function


di ko maintindihan ang gusto mo gawin dito
wala ako makitang sense sa pag retireve mo ng data
nag loop ka sa records tapos sa loob nun nag loop ka sa days ng month
pano mag match ngayon yung record at date?

bakit di mo muna gawin yung calendar for the month
then hanapin mo yung mga cells may same date sa database at dun mo ilagay yung laman?


1. construct calendar muna, wala muna data
2. loop through days of the calendar
3. find records corresponding to that date, if may record then display on that date

iwasan mo muna gumamit ng With para madaling basahin

hwag ka gumamit ng Rs.Fields(1).Value
mas malinaw kung
Rs.Fields("FieldName")
or
Rs!FieldName

pag nagbago ang index ng table mo sira na code mo
 
Re: [TUT] VB6 MSAccess Sample using ADO

@Programmador09

Can you check this line:
If wDate = DateValue(Rs.Fields(1).Value)

...and this line:
Dim wDate As Long

Can you match this two different data types in vb6 (i.e the value returned by DateValue function and wDate variable?
 
Re: [TUT] VB6 MSAccess Sample using ADO

di ko maintindihan ang gusto mo gawin dito
wala ako makitang sense sa pag retireve mo ng data
nag loop ka sa records tapos sa loob nun nag loop ka sa days ng month
pano mag match ngayon yung record at date?

bakit di mo muna gawin yung calendar for the month
then hanapin mo yung mga cells may same date sa database at dun mo ilagay yung laman?


1. construct calendar muna, wala muna data
2. loop through days of the calendar
3. find records corresponding to that date, if may record then display on that date

iwasan mo muna gumamit ng With para madaling basahin

hwag ka gumamit ng Rs.Fields(1).Value
mas malinaw kung
Rs.Fields("FieldName")
or
Rs!FieldName

pag nagbago ang index ng table mo sira na code mo


Code:
Public Function display1(grd As MSFlexGrid)
    If Rs.State = 1 Then Rs.Close
    SQL = "SELECT * FROM Tbl_Cal"
    Rs.Open SQL, Con
    
    Dim First_Day As Long
    Dim Last_Day As Long
    Dim First_Col As Long
    Dim NumofRow As Long
    Dim Cal_Row As Long
    Dim Cal_Col As Long
    Dim Ctr_Date As Long
    
   [COLOR="#008000"] '   First day of the month[/COLOR]
    First_Day = DateSerial(Year(Date), Month(Date), 1)
    [COLOR="#008000"]'   Last day of the month[/COLOR]
    Last_Day = DateSerial(Year(Date), Month(Date) + 1, 1) - 1
   [COLOR="#008000"] '   First Col start with the first day of the month as sunday[/COLOR]
    First_Col = Weekday(First_Day, vbUseSystemDayOfWeek) - 1
    [COLOR="#008000"]'   Determine the number of rows as the number of week in a month (all sunday and  there are always 4 or 5)[/COLOR]
    NumofRow = DateDiff("ww", First_Day, Last_Day, vbUseSystemDayOfWeek) + 1

    
   [COLOR="#008000"] ' Set grid with no fixed cols and rows[/COLOR]
    grd.FixedCols = 0
    grd.FixedRows = 0
    
    [COLOR="#008000"]' Number of days in a week[/COLOR]
    grd.Cols = 7
    
    [COLOR="#008000"]' Multiple Number of rows[/COLOR]
    grd.Rows = NumofRow * 2
    
    Cal_Row = 0
    [COLOR="#008000"]' set to 0 the count index of first day of the month[/COLOR]
    Cal_Col = First_Col - 1
    
   [COLOR="#008000"] ' Set Date range from first day to the last day of month[/COLOR]
    For Ctr_Date = First_Day To Last_Day
        
       [COLOR="#008000"] '   Row and Col Counter[/COLOR]
        Cal_Col = Cal_Col + 1
        If Cal_Col > 6 Then         [COLOR="#008000"]' Column Counter limit for 7 columns or 7 days[/COLOR]
            Cal_Row = Cal_Row + 2   [COLOR="#008000"]' when column counter reach in 7 then skip 1 row[/COLOR]
            Cal_Col = 0            [COLOR="#008000"] ' Then Start again in Column 0 or first day in a week (Sunday)[/COLOR]
            
        End If
        
       [COLOR="#008000"] ' Set Col as 7 column with a number of days[/COLOR]
        grd.Col = Cal_Col
        [COLOR="#008000"]' Set row as row with a number of days[/COLOR]
        grd.Row = Cal_Row
        [COLOR="#008000"]' set Col width[/COLOR]
        grd.ColWidth(grd.Col) = 1100
        [COLOR="#008000"]' Set row Height[/COLOR]
        grd.RowHeight(grd.Row + 1) = 1000
        
        [COLOR="#008000"]' DISPLAY textmatrix string as number of days being looped as Ctr_Date from the firstday to the lastday of month[/COLOR]
        grd.TextMatrix(grd.Row, grd.Col) = Format(Ctr_Date, "d")
        
       [COLOR="#008000"] 'DISPLAY textMatrix String under the number of Days[/COLOR]
        grd.TextMatrix(grd.Row + 1, grd.Col) = "Event Cell"
        
        [COLOR="#008000"]'   Color the Cell header with a number of day YELLOW when Ctr_Date reach to Current Date[/COLOR]
        If Ctr_Date = Date Then grd.CellBackColor = vbYellow
        
       [COLOR="#008000"] '   Skip to The Cell Event line Rows[/COLOR]
        grd.Row = Cal_Row + 1
        [COLOR="#008000"]'   Color the Cell Event Cell GREEN when reach to Current Date[/COLOR]
        If Ctr_Date = Date Then grd.CellBackColor = vbGreen
        
        
    Next Ctr_Date



End Function


Ito po sir medjo malinaw na sana yan basic display po ya ng month view withouth any retrieval function from database just a display of Number of days and Cell Caption under the specified Number of days

hope you can find some way how to display data in the cell event from database when the Ctr_Data is equals to the rs.fields("EventDate")

ito din po yung picture output ng code given above thanks po

View attachment 150203
 

Attachments

  • Untitled.png
    Untitled.png
    181.1 KB · Views: 8
Re: [TUT] VB6 MSAccess Sample using ADO

Code:
Public Function display1(grd As MSFlexGrid)
    If Rs.State = 1 Then Rs.Close
    SQL = "SELECT * FROM Tbl_Cal"
    Rs.Open SQL, Con
    
    Dim First_Day As Long
    Dim Last_Day As Long
    Dim First_Col As Long
    Dim NumofRow As Long
    Dim Cal_Row As Long
    Dim Cal_Col As Long
    Dim Ctr_Date As Long
    
   [COLOR=#008000] '   First day of the month[/COLOR]
    First_Day = DateSerial(Year(Date), Month(Date), 1)
    [COLOR=#008000]'   Last day of the month[/COLOR]
    Last_Day = DateSerial(Year(Date), Month(Date) + 1, 1) - 1
   [COLOR=#008000] '   First Col start with the first day of the month as sunday[/COLOR]
    First_Col = Weekday(First_Day, vbUseSystemDayOfWeek) - 1
    [COLOR=#008000]'   Determine the number of rows as the number of week in a month (all sunday and  there are always 4 or 5)[/COLOR]
    NumofRow = DateDiff("ww", First_Day, Last_Day, vbUseSystemDayOfWeek) + 1

    
   [COLOR=#008000] ' Set grid with no fixed cols and rows[/COLOR]
    grd.FixedCols = 0
    grd.FixedRows = 0
    
    [COLOR=#008000]' Number of days in a week[/COLOR]
    grd.Cols = 7
    
    [COLOR=#008000]' Multiple Number of rows[/COLOR]
    grd.Rows = NumofRow * 2
    
    Cal_Row = 0
    [COLOR=#008000]' set to 0 the count index of first day of the month[/COLOR]
    Cal_Col = First_Col - 1
    
   [COLOR=#008000] ' Set Date range from first day to the last day of month[/COLOR]
    For Ctr_Date = First_Day To Last_Day
        
       [COLOR=#008000] '   Row and Col Counter[/COLOR]
        Cal_Col = Cal_Col + 1
        If Cal_Col > 6 Then         [COLOR=#008000]' Column Counter limit for 7 columns or 7 days[/COLOR]
            Cal_Row = Cal_Row + 2   [COLOR=#008000]' when column counter reach in 7 then skip 1 row[/COLOR]
            Cal_Col = 0            [COLOR=#008000] ' Then Start again in Column 0 or first day in a week (Sunday)[/COLOR]
            
        End If
        
       [COLOR=#008000] ' Set Col as 7 column with a number of days[/COLOR]
        grd.Col = Cal_Col
        [COLOR=#008000]' Set row as row with a number of days[/COLOR]
        grd.Row = Cal_Row
        [COLOR=#008000]' set Col width[/COLOR]
        grd.ColWidth(grd.Col) = 1100
        [COLOR=#008000]' Set row Height[/COLOR]
        grd.RowHeight(grd.Row + 1) = 1000
        
        [COLOR=#008000]' DISPLAY textmatrix string as number of days being looped as Ctr_Date from the firstday to the lastday of month[/COLOR]
        grd.TextMatrix(grd.Row, grd.Col) = Format(Ctr_Date, "d")
        
       [COLOR=#008000] 'DISPLAY textMatrix String under the number of Days[/COLOR]
        grd.TextMatrix(grd.Row + 1, grd.Col) = "Event Cell"
        
        [COLOR=#008000]'   Color the Cell header with a number of day YELLOW when Ctr_Date reach to Current Date[/COLOR]
        If Ctr_Date = Date Then grd.CellBackColor = vbYellow
        
       [COLOR=#008000] '   Skip to The Cell Event line Rows[/COLOR]
        grd.Row = Cal_Row + 1
        [COLOR=#008000]'   Color the Cell Event Cell GREEN when reach to Current Date[/COLOR]
        If Ctr_Date = Date Then grd.CellBackColor = vbGreen
        
        
    Next Ctr_Date



End Function


Ito po sir medjo malinaw na sana yan basic display po ya ng month view withouth any retrieval function from database just a display of Number of days and Cell Caption under the specified Number of days

hope you can find some way how to display data in the cell event from database when the Ctr_Data is equals to the rs.fields("EventDate")

ito din po yung picture output ng code given above thanks po

View attachment 863531



wala na ibang gagawin dyan kundi get the data and display

isang cell lang yan so isang record lang kasya, pwede mo i concatenate siguro kung more that 1
or yung cell mo ay pwedeng up to 8 cells ang laman para kasya ang 8 records

either way: get that date>>retrieve data on that date
para ma display

gamit ka ng where sa SELECT mo
nag SELECT * ka agad,
pano kung may 100k records ka na?
need ba iload lahat yun sa memory?
pwede mo naman i select lang yung nasa current month then loop from the data to match the grid date
or loop sa grid date to match record date

dami pwede diskarte
 
Last edited:
Re: [TUT] VB6 MSAccess Sample using ADO

@Programmador09

Can you check this line:
If wDate = DateValue(Rs.Fields(1).Value)

...and this line:
Dim wDate As Long

Can you match this two different data types in vb6 (i.e the value returned by DateValue function and wDate variable?

try to look at the codes above

i changed it from wDate to Ctr_Date and from rs.fields(1).value to rs.fields("EventDate").value

if you can look carefully Ctr_Date was declared to be the variable of First_Day to Last_Day
and the First_day and Last_Day were declared with a DateSerial keyword which returns a serial as long number that refers to a particular Date
which means Ctr_Date span from the first day to the last day of the month and handle serial number of a Date which mean it can return to a certain Date value.


There is a looping method function for the Ctr_Date it will evaluate starting from the first day of the month to the last day of the month
and let us assume that the value of rs.fields("EventDate").value = 12/31/2013

therefore by the looping function when Ctr_Date serialnumber return as Date reach equals to the rs.fields("EventDate").value. Then the next statement under that conditoon will take place.
 
Last edited:
Re: [TUT] VB6 MSAccess Sample using ADO

try to look at the codes above

i changed it from wDate to Ctr_Date and from rs.fields(1).value to rs.fields("EventDate").value

if you can look carefully Ctr_Date was declared to be the variable of First_Day to Last_Day
and the First_day and Last_Day were declared with a DateSerial keyword which returns a serial as long number that refers to a particular Date
which means Ctr_Date span from the first day to the last day of the month and handle serial number of a Date which mean it can return to a certain Date value.


There is a looping method function for the Ctr_Date it will evaluate starting from the first day of the month to the last day of the month
and let us assume that the value of rs.fields("EventDate").value = 12/31/2013

therefore by the looping function when Ctr_Date serialnumber return as Date reach equals to the rs.fields("EventDate").value. Then the next statement under that conditoon will take place.

gumana ba ayon sa gusto mo?

ang simple lang, loop ka sa calendar (after magawa)
sa bawat date hanapin mo sa database kung may record
kung meron then display
 
Re: [TUT] VB6 MSAccess Sample using ADO

...
if you can look carefully Ctr_Date was declared to be the variable of First_Day to Last_Day
and the First_day and Last_Day were declared with a DateSerial keyword which returns a serial as long number that refers to a particular Date
which means Ctr_Date span from the first day to the last day of the month and handle serial number of a Date which mean it can return to a certain Date value.
...

Pls. correct me If I'm wrong, I think DateSerial does not return Long. Since your First_day and Last_Day variables were declared Long, the data returned by DateSerial becomes Long because of these two.
 
Re: [TUT] VB6 MSAccess Sample using ADO

gumana ba ayon sa gusto mo?

ang simple lang, loop ka sa calendar (after magawa)
sa bawat date hanapin mo sa database kung may record
kung meron then display

opo sir nag reretrieve iyun ng data mula sa database kaso isang record lng ang na reretrieve at ito ay iyong pnkahuling record sa db table lng

- - - Updated - - -

Pls. correct me If I'm wrong, I think DateSerial does not return Long. Since your First_day and Last_Day variables were declared Long, the data returned by DateSerial becomes Long because of these two.

Maybe it works that way because i tried to put the DateSerial return value just like this

First_Day = DateSerial(year(Date),Month(Date),1)

And output the result to the msgbox

Msgbox First_Day

and it appeared a number..
 
Re: [TUT] VB6 MSAccess Sample using ADO

opo sir nag reretrieve iyun ng data mula sa database kaso isang record lng ang na reretrieve at ito ay iyong pnkahuling record sa db table lng

- - - Updated - - -



Maybe it works that way because i tried to put the DateSerial return value just like this

First_Day = DateSerial(year(Date),Month(Date),1)

And output the result to the msgbox

Msgbox First_Day

and it appeared a number..

sabi ko nga loop sa dates, find records for each date then display
yung code mo kasi kinuha mo na lahat yung record minsanan
 
Re: [TUT] VB6 MSAccess Sample using ADO

sabi ko nga loop sa dates, find records for each date then display
yung code mo kasi kinuha mo na lahat yung record minsanan

Code:
Public Function display1(grd As MSFlexGrid)
    If Rs.State = 1 Then Rs.Close
    SQL = "SELECT * FROM Tbl_Cal"
    Rs.Open SQL, Con
    
    Dim First_Day As Long
    Dim Last_Day As Long
    Dim First_Col As Long
    Dim NumofRow As Long
    Dim Cal_Row As Long
    Dim Cal_Col As Long
    Dim Ctr_Date As Long
    
[COLOR=#008000]    '   First day of the month[/COLOR]
    First_Day = DateSerial(Year(Date), Month(Date), 1)
[COLOR=#008000]    '   Last day of the month[/COLOR]
    Last_Day = DateSerial(Year(Date), Month(Date) + 1, 1) - 1
[COLOR=#008000]    '   First Col start with the first day of the month as sunday[/COLOR]
    First_Col = Weekday(First_Day, vbUseSystemDayOfWeek) - 1
[COLOR=#008000]    '   Determine the number of rows as the number of week in a month (all sunday and basically there is always 4 or 5)[/COLOR]
    NumofRow = DateDiff("ww", First_Day, Last_Day, vbUseSystemDayOfWeek) + 1


    With grd
    
[COLOR=#008000]    ' Set grid with no fixed cols and rows[/COLOR]
    .FixedCols = 0
    .FixedRows = 0
    
[COLOR=#008000]    ' Number of days in a week[/COLOR]
    .Cols = 7
    
[COLOR=#008000]    ' Multiple Number of rows[/COLOR]
    .Rows = NumofRow * 2
    
    Cal_Row = 0
[COLOR=#008000]    ' 0 by the count of first day of the month[/COLOR]
    Cal_Col = First_Col - 1
    
[COLOR=#008000]    ' Set Date range from first day to the last day of month[/COLOR]
    For Ctr_Date = First_Day To Last_Day
        Rs.MoveFirst


[COLOR=#008000]        '   Row and Col Counter[/COLOR]
        Cal_Col = Cal_Col + 1
        If Cal_Col > 6 Then         [COLOR=#008000]' Column Counter limit for 7 columns or 7 days[/COLOR]
            Cal_Row = Cal_Row + 2  [COLOR=#008000] ' when column counter reach in 7 then skip 1 row[/COLOR]
            Cal_Col = 0         [COLOR=#008000]    ' Then Start again in Column 0 or first day in a week (Sunday)[/COLOR]
            
        End If


[COLOR=#008000]        ' Set Col as 7 column[/COLOR]
        .Col = Cal_Col
[COLOR=#008000]        ' Set row as row with a number of days[/COLOR]
        .Row = Cal_Row
[COLOR=#008000]        ' set Col width[/COLOR]
        .ColWidth(.Col) = 1100
[COLOR=#008000]        ' Set row Height[/COLOR]
        .RowHeight(.Row + 1) = 1000
        
[COLOR=#008000]        ' DISPLAY textmatrix string as number of days being looped as Ctr_Date from the firstday to the lastday of month[/COLOR]
        .TextMatrix(.Row, .Col) = Format(Ctr_Date, "d")
        
       [COLOR=#008000][B] '  DITO PLA DAPAT NILAGAY YNG WHILE LOOP[/B][/COLOR]
        While Not Rs.EOF
        If Ctr_Date = Rs.Fields(1).Value Then .TextMatrix(.Row + 1, .Col) = Rs.Fields(2).Value
        Rs.MoveNext
        Wend
        
[COLOR=#008000]        '   Color the Ctr_Date YELLOW when reach to Current Date[/COLOR]
        If Ctr_Date = Date Then .CellBackColor = vbYellow
        
[COLOR=#008000]        '   Skip to The Cell Event line Rows[/COLOR]
        .Row = Cal_Row + 1


        
        If Ctr_Date = Date Then .CellBackColor = vbGreen
        


    Next Ctr_Date
    
    .Col = First_Col
    .Row = 1


    End With




End Function


SIR NKUHA KO NA!!! WHOOOOOOOOOOO!!! HAPPY NEW YEAR!! WAHAHAHAA!

View attachment 150287

SAlamat SAYO SIR!! WHOOOOOOOOHOOO KONTI NLNG!
NAPASARAP TULOY NEW YEAR CELEBRATION KO WHOOOOOOHOOOOOO!!!
 

Attachments

  • Untitled.png
    Untitled.png
    175.7 KB · Views: 6
Re: [TUT] VB6 MSAccess Sample using ADO

Code:
Public Function display1(grd As MSFlexGrid)
    If Rs.State = 1 Then Rs.Close
    SQL = "SELECT * FROM Tbl_Cal"
    Rs.Open SQL, Con
    
    Dim First_Day As Long
    Dim Last_Day As Long
    Dim First_Col As Long
    Dim NumofRow As Long
    Dim Cal_Row As Long
    Dim Cal_Col As Long
    Dim Ctr_Date As Long
    
[COLOR=#008000]    '   First day of the month[/COLOR]
    First_Day = DateSerial(Year(Date), Month(Date), 1)
[COLOR=#008000]    '   Last day of the month[/COLOR]
    Last_Day = DateSerial(Year(Date), Month(Date) + 1, 1) - 1
[COLOR=#008000]    '   First Col start with the first day of the month as sunday[/COLOR]
    First_Col = Weekday(First_Day, vbUseSystemDayOfWeek) - 1
[COLOR=#008000]    '   Determine the number of rows as the number of week in a month (all sunday and basically there is always 4 or 5)[/COLOR]
    NumofRow = DateDiff("ww", First_Day, Last_Day, vbUseSystemDayOfWeek) + 1


    With grd
    
[COLOR=#008000]    ' Set grid with no fixed cols and rows[/COLOR]
    .FixedCols = 0
    .FixedRows = 0
    
[COLOR=#008000]    ' Number of days in a week[/COLOR]
    .Cols = 7
    
[COLOR=#008000]    ' Multiple Number of rows[/COLOR]
    .Rows = NumofRow * 2
    
    Cal_Row = 0
[COLOR=#008000]    ' 0 by the count of first day of the month[/COLOR]
    Cal_Col = First_Col - 1
    
[COLOR=#008000]    ' Set Date range from first day to the last day of month[/COLOR]
    For Ctr_Date = First_Day To Last_Day
        Rs.MoveFirst


[COLOR=#008000]        '   Row and Col Counter[/COLOR]
        Cal_Col = Cal_Col + 1
        If Cal_Col > 6 Then         [COLOR=#008000]' Column Counter limit for 7 columns or 7 days[/COLOR]
            Cal_Row = Cal_Row + 2  [COLOR=#008000] ' when column counter reach in 7 then skip 1 row[/COLOR]
            Cal_Col = 0         [COLOR=#008000]    ' Then Start again in Column 0 or first day in a week (Sunday)[/COLOR]
            
        End If


[COLOR=#008000]        ' Set Col as 7 column[/COLOR]
        .Col = Cal_Col
[COLOR=#008000]        ' Set row as row with a number of days[/COLOR]
        .Row = Cal_Row
[COLOR=#008000]        ' set Col width[/COLOR]
        .ColWidth(.Col) = 1100
[COLOR=#008000]        ' Set row Height[/COLOR]
        .RowHeight(.Row + 1) = 1000
        
[COLOR=#008000]        ' DISPLAY textmatrix string as number of days being looped as Ctr_Date from the firstday to the lastday of month[/COLOR]
        .TextMatrix(.Row, .Col) = Format(Ctr_Date, "d")
        
       [COLOR=#008000][B] '  DITO PLA DAPAT NILAGAY YNG WHILE LOOP[/B][/COLOR]
        While Not Rs.EOF
        If Ctr_Date = Rs.Fields(1).Value Then .TextMatrix(.Row + 1, .Col) = Rs.Fields(2).Value
        Rs.MoveNext
        Wend
        
[COLOR=#008000]        '   Color the Ctr_Date YELLOW when reach to Current Date[/COLOR]
        If Ctr_Date = Date Then .CellBackColor = vbYellow
        
[COLOR=#008000]        '   Skip to The Cell Event line Rows[/COLOR]
        .Row = Cal_Row + 1


        
        If Ctr_Date = Date Then .CellBackColor = vbGreen
        


    Next Ctr_Date
    
    .Col = First_Col
    .Row = 1


    End With




End Function


SIR NKUHA KO NA!!! WHOOOOOOOOOOO!!! HAPPY NEW YEAR!! WAHAHAHAA!

View attachment 863850

SAlamat SAYO SIR!! WHOOOOOOOOHOOO KONTI NLNG!
NAPASARAP TULOY NEW YEAR CELEBRATION KO WHOOOOOOHOOOOOO!!!


ambagal nyan, pero konti lang naman records mo per month so ok lang

mas maganda pag ikaw naka solve ng problem mo kesa spoonfeeding diba?
 
Back
Top Bottom