Senin, 30 Januari 2012

Re: [MS_AccessPros] Re: highlight a record in a continuous form

 

Hi Giorgio,

The Highlightbox is unbound (no ControlSource).  Its value is set by the cuttent event or the BeforeInsert event
Warm Regards,
Crystal

Microsoft MVP
remote programming and training

Access Basics by Crystal
http://www.AccessMVP.com/strive4peace
Free 100-page book that covers essentials in Access

 *
   (: have an awesome day :)
 *

________________________________
From: giorgio_rovelli

Hi Crystal, what's the control source of the HighlightBox textbox?
Giorgio

--- Crystal <strive4peace> wrote:
>
> Hi Marius,
>  
> the row can be highlighted using conditional formatting and a control to keep track of the primary key (PK), which is set on the form current event.
>
> TO HIGHLIGHT THE CURRENT RECORD IN A CONTINUOUS FORM
>  
> put the following textbox control on your form (I usually put it in the footer since there is often more unused space)
>  
> name --> RecordID_current
> visible --> no
>  
> make the following textbox control in the detail section of your form:
>  
> name --> HighlightBox
> left --> 0
> top --> 0
> width --> width of detail section
> height --> height of detail section, like 0.2
> enabled --> false
> locked --> true
> tabstop --> false
>  
> send this control to the back so it is behind all the other controls in the section (right-click on it and choose Position, Send to Back)
>  
> in the design view of the form, select HighlightBox
>
> since HighlightBox is behind everything, you may need to select it using the object drop-down (1st icon on the formatting toolbar)
>  
> conditional formatting
> condition 1 --> Expression Is
> --> [RecordID] = [RecordID_current]
>
> example to also highlight a new record:
>     [RecordID_current] = nz([RecordID],RecordID_current)
>
> change fill/back color to LIGHT YELLOW or  light gray
> or whatever color you want for your highlight
>  
> If my detail section background is White, I like to use light yellow for a highlight
>  
> WHERE
> RecordID is the name of your primary key field
>  
> then, in the form OnCurrent event, assign a value to the unbound RecordID_current
> being unbound, it will have the same value on every record
>  
> '~~~~~~~~~~~~~~~~~~~~~~~~~
> Private Sub Form_Current()
>    Me.RecordID_current = IIf([NewRecord], 0, [RecordID])
> End Sub
> '~~~~~~~~~~~~~~~~~~~~~~~~~
> '~~~~~~~~~~~~~~~~~~~~~~~~~
> 'weird change needed since Access 2007
> Private Sub Form_BeforeInsert()
>    Me.RecordID_current = me.RecordID
> End Sub
> '~~~~~~~~~~~~~~~~~~~~~~~~~
>  
> where [RecordID] is the controlname (or fieldname) corresponding to your primary key. 
>
> ~~~
> I also put a click event on the highlight box to SetFocus to another control -- because, even though it is not enabled, it will come to the front and cover everything up if it is clicked on!
>
> ... however, you want the Click event to ALSO open another form (first setFocus, then open the form)
>
> since HighlightBox spans your entire detail section, you can put a click event on that control. 
>
> be sure to save the record (if it needs it) before setting focus somewhere else.
>
> ~~~
> Me.NewRecord is true if the form is on a new record.  Throwing this in means that a new record will also be highlighted ... otherwise, in 2007/2010, it will not.  I had to create the BeforeInsert event to make it work as well ... maybe this was a temporary bug and the extra steps are no longer necessary
>
> I used to use
> nz(RecordID,0)
>
> but I changed to
> IIf([NewRecord], 0, [RecordID])
> for 2007/2010 as well
>
>
> ~~~
> I also put a click event on the highlight box to SetFocus to another control -- because, even though it is not enabled, it will come to the front and cover everything up if it is clicked on!
>
> ~~~~~~~~~
>  
> If you are using a datasheet, I believe you will need to set up conditional formatting for each control as you can't use a control that spans the whole line as you can in a continuous form
>  
>
>
> Warm Regards,
> Crystal
>
> Microsoft MVP
> remote programming and training
>
> Access Basics by Crystal
> http://www.AccessMVP.com/strive4peace
> Free 100-page book that covers essentials in Access
>
>  *
>    (: have an awesome day :)
>  *
>
>
>
> ________________________________
>  From: marius
>
> On Access, in a continuous form, if you click a row, it doesn't highligt
> that record. And this is very annoying when you are thousands of
> records.
>
> How can I do to resolve that problem?
>
> I find a way to to this, but it doesn't work in every form and I don't
> know why. This way is to use a text box over the record, and a little
> code and conditional formating for that text box.
>
> Unfortunately, I get OLE server and activX errors all the time.
>
> The annoying thing is that I make many formulars in that way, and some
> works, some d0n't.
>
> Is there a better way to do this?
>

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar