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

Need a form Event to identify when a record pointer has changed on a subform

Status
Not open for further replies.

BJZeak

Programmer
May 3, 2008
230
CA
I am running 2 subforms from a main form with control being given to one of the subforms ... the subform in question does nothing but list a subquery ... what I am doing is traping all keys and button clicks in the subform and calling parent subs to update the second subform ...

Mainform has subFormView and subFormQry where subFormQry has focus and is in datasheet view ... if I click on any field in any row a parent sub frmUpdate() needs to reference a pointer field in the subFormQry using vaPntr = me.subFormQry.Form.pntr however if I use the up/down arrow keys, even though the subform has been updated it is only reading the last/previous row value.

The reason this is happening is because I incorrectly called the parent before the subform had completed its update (called in the last part of the Keydown event ... I know ... "wrong wrong wrong" ... it was a grey moment)

Does anyone know what the most logical form event would be to capture this change? I have tried form.selectchange and datachange but they don't appear to fire.



Also ... using the Form Current event with

Application.RunCommand acCmdSelectRecord ' select entire record row

is only selecting the first field in the first row ... yet this call works properly after the first key stroke ... it just appears to mess up when the form is transfered focus ... I suspect this may be a cart before the horse issue ... perhaps there is a better form Event to be calling this command from?

 
Ok grey matter is starting to stir ... I looked at the list of form events and tried the KEY UP event for the first issue ... with carefully filtered logic in the Key up and down events I have been able to fix the record pointer issue.

The other issue is just an annoyance factor ... would be nice to have a solution if anyone knows a quick solution

Application.RunCommand acCmdSelectRecord ' select entire record row in datasheet view

not alway highlighting entire row from form.current event

(note I have trapped all the click and double click events for all the data sheet fields so they all trigger this function)
 
On a form with a formatted subform, you can accomplish this thru Conditional Formatting. Create a rectangle, overlay your field cells over the rectangle, and then use Conditional Formatting to change the rectangle back ground color.

On a form with a table as a subform, this code will highlight the row that has the focus:

Me.MySubFormName.Form.SelLeft = 1
Me.MySubFormName.Form.SelWidth = 99 'adjust as needed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top