Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional Format expression when record is Dirty

Status
Not open for further replies.

vpellerito

Technical User
Sep 12, 2006
30
US
Is there an expression I can place in the Conditional Format of my datasheet that works when the current record is being editted (Dirty)?

I have used VBA code for the Form_Dirty event in the past but this only works for Form views, not Datasheet views.

Thanks.
Vince
 
How are ya vpellerito . . .

So whats wrong with using the [blue]Dirty[/blue] property?
Code:
[blue]   If Me.Dirty then
      [green]'Do This![/green]
   Else
      [green]'Do That![/green]
   End If[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
vpellerito

Code:
[blue]   Me.Dirty = True[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
The Dirty property doesn't seem to work when the form is viewed as a datasheet.

I could make the form Continuous and try to mimic the functionality of Datasheet view but that option seems like it would take more time than it's worth.

I was looking for a way to change the format of the record/field when its "Dirty" and viewed as a Datasheet.

Vince
 
Bottom line: stay away from Datasheet view as you loose LOT of form's possibilities ...
 
The Dirty property does, indeed, work when the form is viewed as a datasheet! To prove this, try this code in your form:

Code:
Private Sub Form_Dirty(Cancel As Integer)
 MsgBox "The Form is Dirty!"
End Sub

The problem, I expect, is that you're trying to do something, formatting-wise, that Access doesn't allow in Datasheet View, such as changing the background color of the text box. In Datasheet View, you're stuck with the colors as set in Windows.

You can go into Design View for a Datasheet form, go to Properties and set the back color to, say, red. In Design View it will appear red, but when you run the form in Datasheet View it will be white.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Thanks Missinglinq.
I misspoke when I said the Dirty property doesn't work. I did mean that the formatting I wanted wasn't showing through in Datasheet view like I had coded.
Which was why I was looking for a an expression to add to the Conditional Formatting of the form that would take in Datasheet view. The problem I have is that I don't know of an expression, that I could add as a Conditional Format, that would show when the field is being edited.

I can change format in Datasheet view when the field has focus or has a particular value but, apparently, I can't designate a format change in Conditional Format when the field is "Dirty".

Thanks everybody for your help, though.
Vince
 

As PHV said, you really do lose a lot of functionality using DataSheet View. The main reason that it's included in Access is to provide a bare-bones method of displaying related records, such as in a subform, and bare-bones is what you get! Using a DataSheet View as a primary form is, as John Vinson, MVP said "Committing Spreadsheet by Access!"

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
You can use a version of the method suggested by RoyVidar for highlighting the current record (thread702-958217). You can use the unbound control suggested in the post to hold the ID of the 'dirty' record:

Code:
Private Sub Form_Dirty(Cancel As Integer)
Me.txtTest= Me.ID
End Sub

The condistional format would be:

[tt]Expresion Is: [ID]=[txtTest][/tt]

The unbound control txtTest can be set to Null or zero in a suitable event.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top