In the Handicap UDF, there’s a call to another UDF: GetStartingHC. Every golfer has a handicap to start and it’s stored in TblPlayers. For most golfers, it’s a carry over from last season. For new members, it can be their USGA handicap. When a golfer doesn’t have three scores, the starting handicap is used as one of the scores.
Dim rsPlayers As ADODB.Recordset
Const sBEGHC As String = “BegHC”
If gadoCon Is Nothing Then
Set rsPlayers = New ADODB.Recordset
rsPlayers.Open “TblPlayers”, gadoCon, adOpenDynamic
rsPlayers.Find “Player = “ & lPlyr
If Not rsPlayers.EOF Then
GetStartingHC = CLng((rsPlayers.Fields(sBEGHC) / 0.8) + 36)
Nothing too fancy, just using the Find method to get to the proper record quickly. This recordset is definitely a candidate for moving global so it doesn’t need to be created and destroyed every time the function is called. I so skillfully created a constant to refer to the field in the recordset, but I leave 0.8 and36 as literals. Shameful. If this program will ever be useful outside of my league, those are going to be user settings. I need to make them user settings right now instead of being so lazy.