Jumat, 29 November 2013

RE: [MS_AccessPros] Formating question

 

Bryan-

 

If you still have Conditional Formatting active, that could be interfering.  If it was working in Conditional Formatting, why do you want to try to do it in code?

 

John Viescas, Author

Microsoft Access 2010 Inside Out

Microsoft Access 2007 Inside Out

Microsoft Access 2003 Inside Out

Building Microsoft Access Applications

SQL Queries for Mere Mortals

http://www.viescas.com/

(Paris, France)

 

 

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Bryan
Sent: Friday, November 29, 2013 6:13 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] Formating question

 




John,

I have a break in the code on the “If Me.Site_Visit_Occured Then” line

 

I can see that the Flag follows the first record, not the individual records.

 

It’s bugging me cause I cannot find where the field gets “locked” at.

 

Could there be something on the design page that is controlling it?

 

Thanks,

B

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of John Viescas
Sent: Friday, November 29, 2013 11:47 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] Formating question

 

 

Bryan-

 

The Format event should fire for each record in the Detail section, so each record should be handled individually.  You could try putting a halt in your code at the beginning, then switch to Print Preview and single step through the code to see what it is actually doing.

 

By the way, I prefer using variable names that make it clear the declared data type.  I would have used:

 

Dim intFlag As Integer, datK As Date

 

This isn't too important for a short bit of code, but it sure helps when you've written a long procedure and encounter on the 50th line or so something like:

 

    k = Me.[_Site Visit]

 

It's much clearer that you're dealing with a date value if it reads:

 

    datK = Me.[_Site Visit]

 

John Viescas, Author

Microsoft Access 2010 Inside Out

Microsoft Access 2007 Inside Out

Microsoft Access 2003 Inside Out

Building Microsoft Access Applications

SQL Queries for Mere Mortals

http://www.viescas.com/

(Paris, France)

 

 

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Bryan
Sent: Friday, November 29, 2013 5:27 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Formating question

 





Hello again…..

I’m now trying to “teach” myself some formatting on a report.

The previous creator of the report used a mix of vba and conditional formatting in the report.

Short version:

From the database, we have a project code, a site visit date and a site visit occured checkbox

Using conditional formatting:

1)      If the checkbox is checked, then the date is underlined.

2)      If the date is yet to occur, no formatting.

3)      If the date is past the current date, then the date is bold.

In vba I have the bold part working, but the underline is not working.  The current search query returns 2 records.

What is happening is:

1)      When record #1 is checked, both cells are underlined

2)      When only record #2 is checked, no underlining at all

3)      When both records are checked, both cells are underlined

Trying to figure out why record #2 won’t underline when it is the only one checked?

This is what I have so far –

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

Dim Flag As Integer

Dim k As Date

 

'Set Occured or Past Status

g = Code   ‘project code for test tracking

Flag = Site_Visit_Occured

If Me.Site_Visit_Occured Then

    Me.[_Site Visit].FontUnderline = True

Else

    If Me.[_Site Visit] <> "N/A" Then

        k = Me.[_Site Visit]

        If k < Date Then

            Me.[_Site Visit].FontBold = True

        Else

            Me.[_Site Visit].FontUnderline = False

            Me.[_Site Visit].FontBold = False

        End If

    End If

End If

 

End Sub

Thanks

B





 




__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (4)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar