T
trekgoes2malaysia
I am trying to go to a specific record on a form that opens when a
user clicks on a certain control on a parent form. Problem is I
can't get it to go to the specific record. Instead I get the following
error "Microsoft Office Access can't move the focus to the control
id.". Below are 2 methods of code I used but both return the same
error. What am I doing wrong???
Method 1:
Dim stDocName As String
Dim getathlete As Integer
getathlete = Me![athleteid1]
stDocName = "Cyclists"
DoCmd.OpenForm stDocName ' open form when control is
clicked
[Forms]![Cyclists]!id.SetFocus ' goto record number
control
DoCmd.FindRecord id = getathlete ' find record
Method 2:
Dim stDocName As String
Dim stcontrol As String
Dim getathlete As Integer
getathlete = Me![athleteid1]
stcontrol = "id"
stDocName = "Cyclists"
DoCmd.OpenForm stDocName ' open form when control is clicked
DoCmd.GoToControl stcontrol ' goto record number control
DoCmd.FindRecord getathlete ' find record
user clicks on a certain control on a parent form. Problem is I
can't get it to go to the specific record. Instead I get the following
error "Microsoft Office Access can't move the focus to the control
id.". Below are 2 methods of code I used but both return the same
error. What am I doing wrong???
Method 1:
Dim stDocName As String
Dim getathlete As Integer
getathlete = Me![athleteid1]
stDocName = "Cyclists"
DoCmd.OpenForm stDocName ' open form when control is
clicked
[Forms]![Cyclists]!id.SetFocus ' goto record number
control
DoCmd.FindRecord id = getathlete ' find record
Method 2:
Dim stDocName As String
Dim stcontrol As String
Dim getathlete As Integer
getathlete = Me![athleteid1]
stcontrol = "id"
stDocName = "Cyclists"
DoCmd.OpenForm stDocName ' open form when control is clicked
DoCmd.GoToControl stcontrol ' goto record number control
DoCmd.FindRecord getathlete ' find record