Extracting golf score data

  • Thread starter Thread starter Guest
  • Start date Start date
Mark-
Any chance you'd be willing to share your database with me? I'm trying to
figure out the best way to keep stats for a college golf team.

Thanks!
Nida

Mark Senibaldi said:
With very little tweaking, this worked perfectly. Thanks a lot for
everyone's help.
--
MSS


Barry said:
This is the code I am using for the form I have to enter and/or edit scores.
The other code was from my form for courses and was triggered by a command
button. I hope that this is more helpful.

Private Sub cboTees_AfterUpdate()

'Fill form with course details ie par, yardage,handicap

Dim FindIt As Integer
Dim MyForm As Form
Dim i As Integer
Dim db As Database
Dim rst As Recordset
Dim Criteria As String
Dim ParControl, YardControl, HandicapControl, PuttControl, ScoreControl

'Check to see if Course & Tee exist
FindIt = DCount("[CourseID]", "tblCourseDetails", "[CourseID] = " &
Me!cboCourse & " And " & "[teeID] = " & Me!cboTees)
Set MyForm = Forms!frmRoundsNew

Set db = CurrentDb
Criteria = "[CourseID] = " & MyForm!cboCourse & " and " & "[TeeId] = " &
MyForm!cboTees
Set rst = db.OpenRecordset("select * from tblCourseDetails " & _
"Where " & Criteria)

'"[CourseID] = " & MyForm!cboCourse & " and " & "[TeeId] = " &
MyForm!cboTees)

'Fill fields from recordset
If FindIt > 1 Then
rst.MoveLast
rst.MoveFirst
'Fill the form from the recordset
For i = 1 To 18
ParControl = "Par" & i
YardControl = "Yardage" & i
HandicapControl = "Handicap" & i
'PuttControl = "Putt" & i
FHControl = "FH" & i
'GIRControl = "GIR" & i
Me(ParControl).Value = rst!Par
'Disable the FairwayHit Control on Par 3s
If Me(ParControl).Value = "3" Then
Me(FHControl).Enabled = False
Else
Me(FHControl).Enabled = True
End If
Me(YardControl).Value = rst!Yardage
Me(HandicapControl).Value = rst!Handicap
rst.MoveNext
Next i

Else 'Clear all the fields and get ready for new record
For i = 1 To 18
ParControl = "Par" & i
YardControl = "Yardage" & i
HandicapControl = "Handicap" & i
ScoreControl = "Score" & i
PuttControl = "Putt" & i
FHControl = "FH" & i
GIRControl = "GIR" & i
Me(ParControl).Value = 0
Me(YardControl).Value = 0
Me(HandicapControl).Value = 0
Me(ScoreControl).Value = 0
Me(ScoreControl).ForeColor = 0
Me(PuttControl).Value = 0
Me(FHControl).Enabled = True
Me(FHControl).Value = False
Me(GIRControl).Value = False
Next i
End If

Score1.SetFocus

End Sub

Mark Senibaldi said:
When using this code, I am getting a compile error (sub or Function not
defined) on line: HolePar(i) = Me(ParControl).Value

I'm using this code on the afterupdate event on my cbotee since that should
drive what information is being shown on the for as far as Par, Yards, etc...
goes.

I created an unbound form with text boxes and named them Par1, Par2, etc...
Yards1, yards2, etc...

Any thoughts? Do i need a separate sub or function in my modules?
--
MSS


:

Wow! Sorry I've been MIA for all of this. I have created a form with
unbound text boxes to hold my data. I have named them Par1, Par2, Yards1,
Yards2, Handicap1, Handicap2 etc. Then I looped through the form to load an
arrays for each of the 18 elements. Next I check to see if the round is new
or if I am updating a record and perform the appropriate action, AddNew or
Edit. I don't know if it's the best job in the coding world but it looks
like this.

Dim ParControl As String, YardsControl As String, HandicapControl As
String

'Load up All the Arrays
For i = 1 To 18
ParControl = "Par" & i
HolePar(i) = Me(ParControl).Value
YardsControl = "Yardage" & i
HoleYards(i) = Me(YardsControl).Value
HandicapControl = "Handicap" & i
HoleHandicap(i) = Me(HandicapControl).Value
HoleNumber(i) = i
Next i


'Set criteria to check if record with course and tee ids exist
'Add if new record, edit if already exists
Criteria = "[CourseID]=" & MyForm!CourseID & " and " & "[TeeID]=" &
MyForm!cboTee
Set rst = db.OpenRecordset("select * from tblCourseDetails " & _
"Where " & Criteria)

If rst.RecordCount = 0 Then 'Add new record
For i = 1 To 18
rst.AddNew
rst!CourseID = MyForm!CourseID
rst!TeeID = MyForm!cboTee
rst!HoleNumber = i
rst!Par = HolePar(i)
rst!Yardage = HoleYards(i)
rst!Handicap = HoleHandicap(i)
rst.Update
Next i
Else
For i = 1 To 18
rst.Edit 'Edit existing record
rst!CourseID = MyForm!CourseID
rst!TeeID = MyForm!cboTee
rst!HoleNumber = i
rst!Par = HolePar(i)
rst!Yardage = HoleYards(i)
rst!Handicap = HoleHandicap(i)
rst.Update
rst.MoveNext
Next i
End If

rst.Close
db.Close


Let me know what you guys think! Thanks.

Barry
:

Thx. That must be what I'm missing (the VBA coding to do this). Does anyone
know where I can find a sample dbase that does this?
--
MSS


:

If the form were unbound then you would use recordsets and vba to
populate the controls. And then after the user saves the record you
would use vba to save the data.


On Sep 14, 2:58 pm, Mark Senibaldi
How would I get reference data on the form if it's unbound? For example, I
would like to see the yardage & par for each hole that I am entering data
for. I would like to enter Strokes, Fairways, GIR and # of Putts on the
form. See below for example.

Course: PineValley Golf Course
Hole: 1 2 3
Yards: 315 500 165
Par: 4 5 3
Strokes:
Fairways:
GIR:
Putts:
--
MSS



:
The form would be unbound and you would use recordsets to update the
data.

Place a bunch of text boxes, one for each hole, then when you select
the round and populate the data and click save, the recordsets get
updated.

On Sep 14, 1:58 pm, Mark Senibaldi
Even if I hardcode field names, how would I create a form to input values
Horizontal as opposed to vertically? I can set the form up to do this, but
only by setting the form properties to "single form" but then I can only see
1 hole at a time. I must be missing something- possibly VB Code- that allows
the user to input data Horizontally on a form that uses a vertical table as
the record source. Should I create a temporary table that is Horizontal and
append each value to the Round_Details table?
--
MSS

:
Your table exactly matches Barry's Course Detail table.

Anyways, Barry has assumed that there are 18 holes on a golf course so
he's hardcoded the fields onto his form. Your method works
dynamically and will have to continue to be vertical or follow Barry's
method. Cross-Tab Queries are not updatable as far as I can tell.

Cheers,
Jason Lepack

On Sep 13, 10:26 am, Mark Senibaldi
Thx. My table structure is set up almost identical, with the exception of I
have an additional table:

tbl_CourseHoles
HoleID
CourseID
TeeID
Hole
Par
Yardage
ReportDate

My dilema is figuring how to input my scores(strokes, Fairways, GIR, putts,
etc... onto a form that goes from left to right (like a typical score card)
as opposed to the way I currently have it up and down in a continuous form.
I tried using a crosstab query, but wasn't able to update the tables this way
(it's quite possible I did something wrong) I was hoping to get some guidance
on how he accomplished this.

--
MSS

:
Mark,

Barry's table structure is as such: (based on a previous post)

tblCourse
CourseID
Name
Address
etc.

tblCourseDetails
CourseID
TeeID
Hole
Par
Yardage
Handicap

tblRounds
RoundID
CourseID
GolferID
etc

tblRoundDetails
RoundID
Hole
Score

The CourseDetails table holds the data about the golf holes. The
RoundDetails table holds the scores that the player got on a hole in a
given round.

Cheers,
Jason Lepack

On Sep 13, 9:42 am, Mark Senibaldi
Thanks for the Info Barry.
Is your underlying table set up with a field name for each hole? Or do you
have one field called hole where each hole is a separate record? I have the
 
Great I found some one working on the same project. I am just a beginer golfer and datbase builder. Can you share with me you database so I can get some ideas. Thanks
I have created a database to hold golf scores. The setup is as follows;
tblCourse
CourseID
Name
Address
etc.

tblCourseDetails
CourseID
TeeID
Hole
Par
Yardage
Handicap

tblRounds
RoundID
CourseID
GolferID
etc

tblRoundDetails
RoundID
Hole
Score

I am trying to query for all holes with the par = 3 and have all the scores
for those par 3 holes. I will do the same for par 4 and par5s as well. I
will use this as the basis for a report to show average scores on each of the
holes. Each time I try to create a query I get results that show multiple
entries or entries that are not from the par I have selected and placed
criteria on. Any help is greatly appreciated.
Barry
On Wednesday, July 04, 2007 9:23 AM John Spencer wrote:
Perhaps the following

Query One

SELECT tblRound.RoundID, tblRound.CourseID, Hole, Score
tblRounds INNER JOIN tblRoundDetails
ON tblRounds.RoundID = tblRoundDetails.RoundID

Query two uses the saved query one

SELECT C.Par, Avg(Q.Score)
FROM tblCourseDetails as C INNER JOIN QueryOne as Q
ON C.CourseID = Q.CourseID
AND C.Hole = Q.Hole
GROUP BY C.Par


'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================


Barry wrote:
On Saturday, September 22, 2007 12:32 PM Barr wrote:
Wow! Sorry I've been MIA for all of this. I have created a form with
unbound text boxes to hold my data. I have named them Par1, Par2, Yards1,
Yards2, Handicap1, Handicap2 etc. Then I looped through the form to load an
arrays for each of the 18 elements. Next I check to see if the round is new
or if I am updating a record and perform the appropriate action, AddNew or
Edit. I don't know if it's the best job in the coding world but it looks
like this.

Dim ParControl As String, YardsControl As String, HandicapControl As
String

'Load up All the Arrays
For i = 1 To 18
ParControl = "Par" & i
HolePar(i) = Me(ParControl).Value
YardsControl = "Yardage" & i
HoleYards(i) = Me(YardsControl).Value
HandicapControl = "Handicap" & i
HoleHandicap(i) = Me(HandicapControl).Value
HoleNumber(i) = i
Next i


'Set criteria to check if record with course and tee ids exist
'Add if new record, edit if already exists
Criteria = "[CourseID]=" & MyForm!CourseID & " and " & "[TeeID]=" &
MyForm!cboTee
Set rst = db.OpenRecordset("select * from tblCourseDetails " & _
"Where " & Criteria)

If rst.RecordCount = 0 Then 'Add new record
For i = 1 To 18
rst.AddNew
rst!CourseID = MyForm!CourseID
rst!TeeID = MyForm!cboTee
rst!HoleNumber = i
rst!Par = HolePar(i)
rst!Yardage = HoleYards(i)
rst!Handicap = HoleHandicap(i)
rst.Update
Next i
Else
For i = 1 To 18
rst.Edit 'Edit existing record
rst!CourseID = MyForm!CourseID
rst!TeeID = MyForm!cboTee
rst!HoleNumber = i
rst!Par = HolePar(i)
rst!Yardage = HoleYards(i)
rst!Handicap = HoleHandicap(i)
rst.Update
rst.MoveNext
Next i
End If

rst.Close
db.Close


Let me know what you guys think! Thanks.

Barry
"Mark Senibaldi" wrote:
On Friday, September 28, 2007 2:38 PM Barr wrote:
This is the code I am using for the form I have to enter and/or edit scores.
The other code was from my form for courses and was triggered by a command
button. I hope that this is more helpful.

Private Sub cboTees_AfterUpdate()

'Fill form with course details ie par, yardage,handicap

Dim FindIt As Integer
Dim MyForm As Form
Dim i As Integer
Dim db As Database
Dim rst As Recordset
Dim Criteria As String
Dim ParControl, YardControl, HandicapControl, PuttControl, ScoreControl

'Check to see if Course & Tee exist
FindIt = DCount("[CourseID]", "tblCourseDetails", "[CourseID] = " &
Me!cboCourse & " And " & "[teeID] = " & Me!cboTees)
Set MyForm = Forms!frmRoundsNew

Set db = CurrentDb
Criteria = "[CourseID] = " & MyForm!cboCourse & " and " & "[TeeId] = " &
MyForm!cboTees
Set rst = db.OpenRecordset("select * from tblCourseDetails " & _
"Where " & Criteria)

'"[CourseID] = " & MyForm!cboCourse & " and " & "[TeeId] = " &
MyForm!cboTees)

'Fill fields from recordset
If FindIt > 1 Then
rst.MoveLast
rst.MoveFirst
'Fill the form from the recordset
For i = 1 To 18
ParControl = "Par" & i
YardControl = "Yardage" & i
HandicapControl = "Handicap" & i
'PuttControl = "Putt" & i
FHControl = "FH" & i
'GIRControl = "GIR" & i
Me(ParControl).Value = rst!Par
'Disable the FairwayHit Control on Par 3s
If Me(ParControl).Value = "3" Then
Me(FHControl).Enabled = False
Else
Me(FHControl).Enabled = True
End If
Me(YardControl).Value = rst!Yardage
Me(HandicapControl).Value = rst!Handicap
rst.MoveNext
Next i

Else 'Clear all the fields and get ready for new record
For i = 1 To 18
ParControl = "Par" & i
YardControl = "Yardage" & i
HandicapControl = "Handicap" & i
ScoreControl = "Score" & i
PuttControl = "Putt" & i
FHControl = "FH" & i
GIRControl = "GIR" & i
Me(ParControl).Value = 0
Me(YardControl).Value = 0
Me(HandicapControl).Value = 0
Me(ScoreControl).Value = 0
Me(ScoreControl).ForeColor = 0
Me(PuttControl).Value = 0
Me(FHControl).Enabled = True
Me(FHControl).Value = False
Me(GIRControl).Value = False
Next i
End If

Score1.SetFocus

End Sub

"Mark Senibaldi" wrote:
 
I doubt he's still around - you're replying to a message that's _4 years
old!_
At least do a search and find out if he's still an active poster before
trying to communicate with him like this.
 
Back
Top