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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform datasheet row highlight/unhighlight

Status
Not open for further replies.

BJZeak

Programmer
May 3, 2008
230
CA
using subform current event I can use:

Application.RunCommand acCmdSelectRecord

to highligt a datasheet row ... is there a simple way to then unhighlight the row when the subform is not in focus ... I basically want to see the highlighted row only when the subform is in focus

A requery of the subform from the parent only appears to clear this higlighted line if there is recordclone.recordcount = 0 ... which would mean doing a dumby requery to a blank record then another requery to the current record block

it becomes a bit confusing to determine when a calendar object or the subform is in focus when the row is inconsistantly highlighted
 
Have you tried setting focus to some control on the form to unselect it? It is just a hunch.
 
Just tried using a default button on your suggestion but get a runtime error saying I cannot set focus to it ... suspect that is because it is a control not normally associated with a data sheet ???
 
Maybe... try setting it to one of your existing textboxes.
 
did that too ... once the record has been selected it appears to not care ... even added a state flag so the current event can't trip the application statement when exiting the subform.

Access appears to remember the last row selected regardless of date plus will keep the record selector on until it gets a screen with no data. Not sure how it is handling the subform events though as the current event (which does the application command) fires seemingly at random (expected it would fire when I do a subform requery)

What I have is a subform of date specific records ... the main form has a Calendar obj which I can use to jump or scroll dates ... the subform is updated automatically using a subform requery ... what happens is the first time I tab to the subform the current event sets the record selection. If lets say I select todays date and there are 10 records associated with today and I then scroll to the 3rd record then tab out of the subform, I then scroll to the next date then back the record selector stays highlighted and Access remembers that I was on record 3 ... the only way the record selection turns off is if I go to a date with no records ... then the next day with records is clear of the highlighted row. (except when this random event occurs hitting the subform current event ... only seems to happen when I hold the arrow keys down inside the calendar object)

 
I scanned through the runcommand constants and found nothing.

I hate to do it but I am going to have to recommend my least favorite Access statement.. sendkeys

Either of the below lines will likely work if you execute them from the right place in code or set the focus properly. I recommend the first line... Right arrow then left arrow.

Code:
sendkeys "{RIGHT}{Left}"
sendkeys "{Tab}"


Why are you selecting the record? Maybe there is another alternative.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top