Solved

Ok, Access 2000 and Calendarcontrol

Posted on 2003-12-07
11
200 Views
Last Modified: 2013-12-25
Hi,

Here is my question, I'm new to databases and handling them.
I like to read out an date filed in a access database, and set in a Calendar monthview the date bold.
So if the date exists set it to bold in the monthview.

The access database has an table with: ID | Event | Date | Location | Description | Category

I do not know how to query a access database so if you could give an example it would be very pleased.

Kind Regards, Joleen
0
Comment
Question by:Joleen
  • 4
  • 3
  • 2
  • +1
11 Comments
 
LVL 8

Expert Comment

by:MYLim
ID: 9893833
'Demo about using Ado to retrieve database info
'Please Start VB6.0 application- goto Project - goto Reference - check 'Microsoft ActiveX data Control 2.7 library'
'Also dtpicker inside 'Microsoft Common control 6.0 '

Dim Cnn As ADODB.Connection
Dim Rs As ADODB.Recordset
 
Private sub form_load()
On error goto ErrFound
Dim DbPath as string
DbPath = "C:\Test.mdb"

Set Cnn = New ADODB.Connection
Cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DbPath & ";User Id=admin;Password=;"

Set Rs = New ADODB.Recordset
Rs.CursorLocation = adUseClient
Rs.Open "Select * from Table1", Cnn, adOpenStatic, adLockReadOnly

if Rs.eof = true then
 msgbox "Empty Recordset,Connection will be Close"
 rs.close
 set rs=  nothing

  Cnn.close
 set Cnn = nothing
 
 exit sub
end if

text1.text = rs.fields(0).value & " "
text2.text = rs.fields(1).value & " "


if isnull (rs.fields(2).value) = false then
   dtpicker1.value = rs.fields(2).value
end if

text4.text = rs.fields(3).value & " "
text5.text = rs.fields(4).value & " "

 rs.close
 set rs=  nothing

  Cnn.close
 set Cnn = nothing
 
 exit sub
ErrFound:
msgbox "Err description : " & Err.Description
if rs.state=adstateOpen Then
  rs.close
  set rs = nothing
end if
 
if Cnn.state = adstateOpen then
  Cnn.close
  set Cnn = nothing
end if
end sub
0
 

Author Comment

by:Joleen
ID: 9898931
I'm sorry MYLim,

But you didn't read the question at all.

Joleen.
0
 
LVL 30

Expert Comment

by:nmcdermaid
ID: 9928392
I can't help but say something here, but...

'I do not know how to query a access database' and this is in a VB newsgroup so I guess MYLim assumed you wanted to query a database in VB. You should probably be more specific if you want something else.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:Joleen
ID: 9929086
Yeah I know, but that is not my main question.

Cheers, Joleen
0
 
LVL 30

Expert Comment

by:nmcdermaid
ID: 9929150
Do you mean set a date bold in the flyout calendar view on a date picker? AFAIK it can't be done unless you want to develop your own custom control.



0
 

Author Comment

by:Joleen
ID: 9934746
No I Don't, it should be on a MonthView Control, Do you mean that I have to draw it on a form?

Cheers, Joleen
0
 
LVL 30

Expert Comment

by:nmcdermaid
ID: 9940669
hmmm I can't find a MonthView control and I can't get the Microsoft Calendar Control to work. So sorry, can't help you.
0
 
LVL 8

Accepted Solution

by:
MYLim earned 100 total points
ID: 9940829
inside MSCOMCT2.OCX
check component : Microsoft Windows Common Controls-2 6.0
0
 
LVL 30

Assisted Solution

by:nmcdermaid
nmcdermaid earned 100 total points
ID: 9940861
OK Thanks MyLim.

use this syntax to set a date bold

MonthView.DayBold(#12/20/2003#) = True



So, using some of Lims code...


Rs.Open "Select YourDateField from Table1", Cnn, adOpenStatic, adLockReadOnly

Do Until Rs.eof

  if IsDate(Rs.fields(0).value) then
    MonthView.DayBold(CDate(rs.fields(0).value)) = True
  end if
 
  Rs.MoveNext
Loop


rs.close
set rs=  nothing



This is the basics, what has to be incorporated in here is:

1. The correct name of your MonthView control
2. The correct field and table names
3. Valid MinDate and MaxDate settings
4. A filter on the current month to speed things up, as only one month will can be viewed at a time

If you need any help sorting out those issues, let me know.

Keep in mind that the Bold settings are forgotten when you change the month.

0
 
LVL 29

Expert Comment

by:leonstryker
ID: 11120900
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:

Split MYLim, nmcdermaid

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

leonstryker
EE Cleanup Volunteer
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
I need help formating a date variable in my VB.Net application 2 60
VBA filters 2 64
Add and format columns in vb6 7 63
fso.FolderExists("\\server\HiddenFolder$") 4 76
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question