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!

Go to last record and specified field on subform

Status
Not open for further replies.

skyline666

Programmer
Oct 22, 2007
141
GB
Hi,

I have a form called Category and subform called Risk in an Access 2003 project. I originally wanted the subform to go to the last record when a button called "AddNewRisk" was pressed (which added a new row to the subform), but I have that sorted. What I would like to do is go to the last record as it does now, but also go to a named field aswell (the field being RiskDetails, the second field in the subform). This is becuase the first field, RiskID, is a unique number that gets automatically put in when the add button is pressed. As this is automatically put in, instead of the user having to go to the next field, I would like it to go to the second field when the button is pressed. The code used so far for going to last record is:

Code:
AddNewRisk strRiskID, Me.ProjectID, intSeq, Me.CategoryID
Me.Risk.Requery
DoCmd.GoToControl "Risk"
DoCmd.GoToRecord , , acLast
where the first line is for the command button, second line then refreshes the subform, and the third/fourth line go to the last record.

Many thanks,

Andrew
 
Done it, put Me.Risk!RiskDetails.SetFocus after the gotorecord command, so code is:

Code:
AddNewRisk strRiskID, Me.ProjectID, intSeq, Me.CategoryID
Me.Risk.Requery
DoCmd.GoToControl "Risk"
DoCmd.GoToRecord , , acLast
Me.Risk!RiskDetails.SetFocus

Hope this helps anyone in the future.

Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top