?
Solved

highlight an entire row in Access when record is being adjusted...

Posted on 2005-03-03
16
Medium Priority
?
402 Views
Last Modified: 2008-01-09
I just want to simply have an entire row highlighted on a formDS wherever the cursor is (like when you click the left-most column to select an entire row to delete it).  From the searching that I've done here seems like I would have to come up with something pretty complicated?  Am I wrong?
0
Comment
Question by:stephenlecomptejr
  • 6
  • 6
  • 4
16 Comments
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 1000 total points
ID: 13455077
If it's on a datasheet, it's not really possible. On a continuous form, it may be possible to simulate it, but it won't really have the same effect. You can change the background of the current control fairly easily though.
0
 
LVL 54

Assisted Solution

by:nico5038
nico5038 earned 1000 total points
ID: 13455079
Only like making it "selected" like:
http://www.experts-exchange.com/Databases/MS_Access/Q_20598074.html

Nic;o)
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 13455086
Trouble with selecting the record of course, is that it gets "unselected" when you start editing a field :(
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 54

Expert Comment

by:nico5038
ID: 13455153
That's why I posted "Only" Shane :-)

But perhaps this code could be used:
http://www.comriesoftware.net/codewidgets/product.aspx?key=146

Nic;o)
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 13455173
I was thinking about something similar to that, but I can't for the life of me figure out how to get it to change the bg colour of just the current row.

Actually, I suppose you could use something like the serialise function to number the rows and check if the CurrentRecord property is the same as the row number but that would be veeeerrryyyyy slow and wouldn't work if the user sorted the form.
0
 
LVL 1

Author Comment

by:stephenlecomptejr
ID: 13455385
Private Sub Form_Current()
    DoCmd.RunCommand acCmdSelectRecord
    Me.Refresh
End Sub


I like using the above code.
If there was a way for the form to go to the specific record (row, column) you click on after its highlighted without having to double-click on it would be great!
0
 
LVL 54

Expert Comment

by:nico5038
ID: 13455404
I got the code from the link working with a form and a unique (text) key like:

Option Compare Database
Option Explicit

Private Sub Form_Current()
CurrentDb.Execute ("update tblTest set rs = false where keyfield ='" & pbPrevious & "'")
CurrentDb.Execute ("update tblTest set rs = true where keyfield ='" & Me.KeyField & "'")
pbPrevious = Me.KeyField
End Sub

Private Sub Form_Load()
ResetConditions Me
SetConditions Me
End Sub

And in the modules section:
Option Compare Database
Option Explicit

Public pbPrevious As String
Public pbCurrent As String

Public Sub SetConditions(frm As Form)
''\\THE NEXT LINE WILL IGNORE CONTROLS SUCH AS LABELS AND COMMAND BUTTONS
On Error Resume Next
Dim BColor As Long
Dim ctl As Control
''\\CHANGE THE BACKGROUND COLOR ON THE NEXT LINE
BColor = 14803425
For Each ctl In frm.Controls
With ctl.FormatConditions.Add(acExpression, acNotEqual, "[RS]")
.BackColor = BColor
End With
Next

End Sub

Public Sub ResetConditions(frm As Form)
On Error Resume Next
Dim BColor As Long
Dim ctl As Control
BColor = -2147483633
For Each ctl In frm.Controls
''\\ REMOVE PREVIOUS FORMATS
ctl.FormatConditions.Item(0).Delete
ctl.FormatConditions.Item(1).Delete
ctl.FormatConditions.Item(2).Delete
Next

End Sub

But on my test dataset with 3000 rows the refresh interval (Tools/Options/Advanced) had to be set to 1 sec to get it a bit "responsive" and the table will need to be expanded with the field RS of the Yes/No datatype.

Nic;o)
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 13455443
0
 
LVL 54

Expert Comment

by:nico5038
ID: 13456736
Looks nice, but is a continuous form with transparent fields solution and no datasheet....

Nic;o)
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 13457013
Yes, I couldn't figure out how to set the format conditions for a datasheet (although it was very late and I was quite tired).
0
 
LVL 54

Expert Comment

by:nico5038
ID: 13480951
Hmm, odd I thought my code was exactly solving your question...

Nic;o)
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 13480965
stephenlecomptejr, any feedback?
0
 
LVL 1

Author Comment

by:stephenlecomptejr
ID: 13495824
Nico,... I get an error under Public Sub SetConditions.

highlighting specifically acExpression at the following:

With ctl.FormatConditions.Add(acExpression, acNotEqual, "[RS]")

But of course, I do have Access 97.
0
 
LVL 1

Author Comment

by:stephenlecomptejr
ID: 13495827
How can I add feedback?
0
 
LVL 1

Author Comment

by:stephenlecomptejr
ID: 13495832
In fact, when I type With ctl.  (Format Conditions is not one of my options)
But I betcha probably works in Access 2000 tho.
0
 
LVL 54

Expert Comment

by:nico5038
ID: 13498464
Sorry, won't work under A97 as you need the FormatConditions that have been added in A2000 :-(
Only the "select row" trick will work under all versions.

Nic;o)
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

571 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