Highlight a selected record

I am trying to highlight a selected record of a continuous form.  Conditional
Formatting is not working because it highlights individual fields.  If
Conditional Formatting would highlight the entire row, it would be perfect.

I created a txtBackground text box to size of all my fields, sent it the
back—behind the fields.  Use the txtBackground as the control, but when it
has focus it covers the data.  Below is the code I used:


     Sub HighlightControl(ctl As Control)
         On Error Resume Next
         ctl.BackColor = 65535
     End Sub


     Sub UnhighlightControl(ctl As Control)
         On Error Resume Next
         ctl.BackColor = 16777215
     End Sub


     Private Sub txtBackground_GotFocus()
         HighlightControl Me.txtBackground
     End Sub

     Private Sub txtBackground_LostFocus()
         UnHighlightControl Me.txtBackground
     End Sub

Any suggestions is appreciated.  Thanks!

-- 
Message posted via http://www.accessmonster.com

0
lmcc
5/22/2010 8:30:38 PM
access.modulesdaovba 1670 articles. 0 followers. Follow

2 Replies
1469 Views

Similar Articles

[PageSpeed] 2

lmcc via AccessMonster.com wrote:

>I am trying to highlight a selected record of a continuous form.  Conditional
>Formatting is not working because it highlights individual fields.  If
>Conditional Formatting would highlight the entire row, it would be perfect.
>
>I created a txtBackground text box to size of all my fields, sent it the
>back�behind the fields.  Use the txtBackground as the control, but when it
>has focus it covers the data.  Below is the code I used:
>
>     Sub HighlightControl(ctl As Control)
>         On Error Resume Next
>         ctl.BackColor = 65535
>     End Sub
>
>     Sub UnhighlightControl(ctl As Control)
>         On Error Resume Next
>         ctl.BackColor = 16777215
>     End Sub
>
>     Private Sub txtBackground_GotFocus()
>         HighlightControl Me.txtBackground
>     End Sub
>
>     Private Sub txtBackground_LostFocus()
>         UnHighlightControl Me.txtBackground
>     End Sub


I don't understand what your code is trying to do. or why
you are setting the focus to txtBackground.

You should use Conditional formatting on the big (size of
the details section) txtBackground text box.  You did not
say which record(s?) should be highlighted so I can't say
how to do that.  You may(?) also want to set all the other
text boxes' BackStyle to Transparent.

To prevent the big text box from getting the focus, set its
Enabled to No and Locked to Yes.

-- 
Marsh
MVP [MS Access]
0
Marshall
5/22/2010 11:27:58 PM
Thanks Marshall,

I was trying to delete this thread but could not find how to.  I was
following Tracking the Focus example in a book, which the examples are for
individual controls--not a whole row like I was trying to do.  Anyway,
Conditionally Formatting does what this code does without using VBA.


Marshall Barton wrote:
>>I am trying to highlight a selected record of a continuous form.  Conditional
>>Formatting is not working because it highlights individual fields.  If
>[quoted text clipped - 21 lines]
>>         UnHighlightControl Me.txtBackground
>>     End Sub
>
>I don't understand what your code is trying to do. or why
>you are setting the focus to txtBackground.
>
>You should use Conditional formatting on the big (size of
>the details section) txtBackground text box.  You did not
>say which record(s?) should be highlighted so I can't say
>how to do that.  You may(?) also want to set all the other
>text boxes' BackStyle to Transparent.
>
>To prevent the big text box from getting the focus, set its
>Enabled to No and Locked to Yes.
>

-- 
Message posted via http://www.accessmonster.com

0
lmcc
5/23/2010 1:11:28 AM
Reply:

Similar Artilces:

Selecting Embedded charts in Active Sheets programmatically
I have a workbook with about 15 worksheets. On each worksheet is typically one chart ... unfortunately, the chart name is not always Chart 1. I have this code. For Each sht In ActiveWorkbook.Worksheets sht.Activate 'If sht.ProtectContents = True Then 'sht.Unprotect Password:="" 'End If 'Worksheets(sht).Activate chartcount = ActiveSheet.ChartObjects.Count Debug.Print chartcount If chartcount > 0 Then For j = 1 To chartcount ActiveSheet.ChartObjects("Chart " & j).Activate 'W...

Timed recordings
I'm just about to start building my own media PC, which will primarily serve as a receiver and recorder for digital TV - both from satellite and terrestrial. I'm in the UK, but as the UK newsgroup for Media Center is rather quiet, I thought I'd seek help from both groups. I hope you don't mind the cross-posting. I can't remember the correct terminology, but our broadcasters send some sort of control signal along with the broadcast which indicates the precise start and stop times of each programme (this is in addition to the usual programme guide). It i...

Getting a value from the last record
Hello, I have an inventory database. I have the sum of apples in my last record and want to subtract apples today from it. The value is the last record number from a table: Total apples (in last record) = 25 (new record) sell 5 apples = total apples = 20 me.total_apples = me.sell_apples + (last record me.total_apples) How can I get that last records me.total_apples. I do not have an open internet access so I can not go see alan browns web page only microsoft web pages. Thanks How will Access know what the last records is? Do they contain a DateTime tracking fiel...

How to select record in the subform and to show it in the main form? 09-27-07
Hi I have subform with datasheet view and I need to know how to select record in the subform and to show it in the main form? Thanks Forget my last post. I misuderstood your question. The code I gave will give the record "number" (sort o count from the table start) not the refered to record. -- Wayne Manchester, England. "Wayne-I-M" wrote: > Hi > > There are other methods but a simple one to use would be > > DoCmd.GoToRecord acForm, "MainFormName", acGoTo, > Forms!MainFormName!SubFormName.Form!LinkIngPrimaryField > > Chan...

Record counter for navigation
I have eliminated the navigation buttons on my form and replaced them with command buttons. Now how do I make a textbox show a record count just like the standard record counter? This counter would not be bound to any field in the table, but would just be a count starting with 1 of whatever records comprise the current query. I'm doing this to have more control over the appearance of the buttons and counter. Robert Try a text box with Control Source of: =[Form].[CurrentRecord] More info in: Numbering Entries in a Report or Form at: http://allenbrowne.com/casu-10....

Updating New Record form
Hi, I have two tables set up: tblDeals and tblEquip, they have one field in common called: DealCode. I have a query qryEquip that links the two tables based on the DealCode field and adds other tblDeals fields like Customer, Description, etc, to help identify the deal but only the DealCode is stored in the Equip table. Form frmEquip is based on query qryEquip and it is working fine. Here’s what I’m trying to do: When I add a new Equip record I want to be able to look into the tblDeals for the right deal and then pass the DealCode to the frmEquip, then have the frmEquip pull the rest o...

Copying records from one (sub)form to another subform using Append
I have a mainform with products (and thier details) from a products table and a subform showing ingredients (from an ingredients table). I wish to select existing ingredient records from one subform and copy them to so that they appear as ingredients in a new Mainform. I have a selection box next to each of the ingredients to enable selection but how do I "copy" these selections to the new record on the new mainform. Do I use an append query to do this? Any guidance on doing this would be great (not too experienced in this area). Many Thanks On Tue, 9 Feb 2010...

Not able to add or edit records from an input form.
Hi, I have an MS Access input form that is based on a query that is based on a table called Training. The Training table is actually an SQL Server table that is linked. There are three fields in the table: ID (The primary key), CustomerName and TrainingDate. I added three records into the table using SQL Server Enterprise Manager and can add more. However, I can't add them using my access form. I can view them but cannot add. I can't edit them either. What setting do I make to allow edit and adding to occur? I posted this question in the sql server forum and was ...

In Excel 2000, How do you select the whole of a worksheet (Select.
In Excel 2000, How do you select a whole worksheet (Select All) with ONE click of the mouse? Cheers!! click on that little grey button to the right of the column headers and at the top of the row headers. Using the keyboard (you didn't ask!). Ctrl-a (twice in xl2003.) Rascal wrote: > > In Excel 2000, How do you select a whole worksheet (Select All) with ONE > click of the mouse? Cheers!! -- Dave Peterson ...

Cannot record macro in excel
If you cannot record macro in microsoft excel. I found one reason for that. Reason for this was security righs in registry. My case was this: We have Windows 2000 AD domain.We use compatws.inf template in group policy to give more rights to normal domain users. Situation was this: I cloned PC from image and in first boot i installed f-secure to PC. This installation added one registry key to hklm/software/classes/clsid and gave this key security righs to averyone . This key did not have permission to inherite permissions from upperlevel. Thats why security templates hangs and users did...

Selection Criteria for Statements
When printing statements, no matter what type of seleciton criteria we enter (ie, print only statements for customers with balance > 0) all statements print. Any ideas ? Store Operations 1.2 SP1 ...

Recording multiple checks in a single deposit
This seems like it's probably brutally simple, but I can't figure it out: how do I record multiple check numbers in a single deposit? The deposit consists of a couple checks from my primary checking account which I'm depositing, along with some cash, as a single deposit transcation in a different checking account. Using MS Money Deluxe 2003. - sph In microsoft.public.money, hodgdon wrote: >This seems like it's probably brutally simple, but I >can't figure it out: how do I record multiple check >numbers in a single deposit? > >The deposit consist...

Checking for new records
I am new to VBA and need to call "TravelForm" from the "MeetingsForm" It should open in to a new travel with travel info from "tbltravel" filled in. I tried the following code in the "on Click" property of the calling button in the MeetingsForm. Private Sub btnTravel_Click() On Error GoTo Err_btnTravel_Click Dim DocName As String DocName = "frmTravel" DoCmd.OpenForm DocName, OpenArgs:=Me![Order_Num] Exit_btnTravel_Click: Exit Sub Err_btnTravel_Click: MsgBox Error$ Resume Exit_btnTravel_Click End Sub Then on the T...

Selection Mode Stuck
I've accidentally put Excel (Office 2003, w/latest updates) into a sticky selection mode on this one spreadsheet file and I can't turn it off. I apparently hit a key combo (I think with a mouse click) and now when I open this file and single click on any cell, that cell is selected and the selection extends in both directions as I move the mouse. I can't click on any buttons, or toolbar icons, or do anything to stop this selecting mode. It just goes on and on, autoscrolling to infinity. I eventually have to CTRL-ALT-DEL to kill Excel, just to free up my computer. Any help wou...

OwnerDrawn ClistCtrl and full row selection
Hi all, I have an owner drawn CListCtrl in report mode, and I'm drawing the highlight for a full row selection. This seems simple enough but it really is far more complicated. Using the HDC given though DrawItem, I draw a FillSolidRect(...) with the width of the window. Unfortunately it onlys draws up to the end of the last column. At first I thought this was a clipping problem but SelectClipRgn(NULL); does nothing. I thought I'd be cleve and created a CClientDC dc(this ) to do the row selection. This does work, however there seems to be a random non drawing of certain rows. ...

"No resource have been selected for this activity"?
When creating an appointment by clicking the "follow up" button on the screen of a contact, after I fill out the fields on the form assistant and click "Save and Open", I would get this message "No resource have been selected for this activity". Why? and how to get rid of this warning? Thx. ------=_NextPart_0001_0A0CD6AA Content-Type: text/plain Content-Transfer-Encoding: 7bit <phw@discussions.microsoft.com> wrote: > When creating an appointment by clicking the "follow up" button on the screen > of a contact, after I fill out the field...

How to have auto dialog box showing when selecting cell
I would like to have a dialog box appear each time a cell is selected in a column. I need the dialog box show the next cheque number and allow the user to change that if necessary. The cells cannot have a formula in it as that would cause problems when sorting. Is there a way to do this? Rob You could use data validation to do this. Firstly in an empty area of the worksheet define a cell that is equa to max(column range where the cehque numbers are shown) + 1. (ie max(a:a) + 1 Then set the data validation for the whole cheque input range to list list = the address of the new cell. Th...

Detail record prints on top of group header subreport
Hello, I have a report with a subreport in the group header. Both the detail and subreport have two columns (width 3"). Column layout across, then down. The first record of the detail section prints in the header section on the right side, on top of the second record of the subreport. Thanks in advance for your help. Ellen ...

deleting a record after copying data
I currently have code in a form called workorders to execute after update to copy data over to a new form called Closed_Workorders. using two different tables (tasks and closed tasks) How do I write the code to delete the record once it is copied. "Thanks for your Support" Here is the code: Private Sub Status_AfterUpdate() If Status = "Completed" Then Dim StDocName As String Dim StDocnbr As String StDocName = "Completed_WorkOrders" StDocnbr = [Log_Number] DoCmd.OpenForm StDocName DoCmd.GoToRecord , , acNewRec Forms![Completed_WorkOrders]...

Dragging to select multiple rows causes out of control scroll
When I select a number of rows by click and drag method, the rows scroll by too fast to control. Is there a way to slow down this scrolling? "ronlee67" <ronlee67@discussions.microsoft.com> wrote in message news:D2940A38-DDA3-4E4B-B41A-FCEFAA3ADACA@microsoft.com... > When I select a number of rows by click and drag method, the rows scroll > by > too fast to control. Is there a way to slow down this scrolling? Hi Roplee67, You can change the scroll speed of your mouse: Start | Control Panel | Mouse | Wheel | Scrolling Depending on your OS version, access to ...

Graceful Method Of Making Single Record Non-Editable?
I've got a continuous list subform. One of the rows is identified by !IsBuyDependent=True. I want this row, but none of the others tb non-editable. My best shot so far is: -------------------------------------- Private Sub txtResetDate_Enter() With Me If .txtIsBuyDependent = True Then Beep .txtDummy.SetFocus End If End With End Sub ------------------------------------- Where .txtDummy is an unbound field with .BackStyle and .BorderStyle = Transparent; ..TabStop=False - sitting over top of a percent label on the same line. Screen snap at http://tinyurl.com/37m...

Select Query Broken
Does any one know, of the issue in A2k3 With the Query, I was creating some combo list filters, via query's then putting the SQL in a Marco Apply filter. work great then all i sudden, now, when i view the query in normal mode, (NOT Design mode) Its Showing all the fields that are related on the table the query is based on, even though only two fields have been selected. and the show tick is ticked? just for 2, any ideas whats happening here? ive tried repairing and compacting database and also restarting access no luck? On 10 Sep, 16:42, KARL DEWEY <KARLDE...@discussions.microsoft...

Accessing fields on Record Source without putting them on form/subform
I have a database designed to maintain family membership information. I have a mainform and subform. The subform draws data from tbl_family, which contains fields - household_id, family_member_id, and relationship plus others. Please note that Head of Household (coded AA) is one of the selections for Relationship field. On subform, each time the user selects a different person to be the Head of Household, the relationships for all family members reset to blank, except the one person just selected for head of household. Here is my working codes: ************ Private Sub cboRe...

Combo box auto-select question
I have a combo box with several columns, when I click the down arrow I see a scrollable list of all the columns. However, when I type into the combo box it only pops up the nearest entry in the first column. Is there any way to get it to popup ALL of the columns of the nearest row when I type in the box? Thanks. Only by clicking the drop down arrow. "zz" wrote: > I have a combo box with several columns, when I click the down arrow I see a > scrollable list of all the columns. However, when I type into the combo box > it only pops up the nearest entry in the first co...

Add Records Sequentially with DMAX
Where is the proper place in my form to add the following Area Table CostCodeLast3 CostCode 1000 001 10-001 1100 001 11-001 1200 001 12-001 002 12-002 003 12-003 I want the next cost code to pop up after I enter the area in a new record. I know how to combine the last 3 with the first 2 numbers of the area. I don't know how to make the code select the next last 3 for area. -- Message posted via http://www.accessmonster.com Dan,...