This database I put together to organize sports teams is working pretty well. Only one problem.
My TEAMS to PLAYERS is a ONE to MANY relationship.
On my form the TEAM record is on the main form and the PLAYERS are picked using combo boxes on a continuous sub form. It works great and is quick, except when you type a name in the combo box and then change your mind and try to back space the name out and then hit the close button.
I know if I hit the ESC button first it will back out the record, but if I try to back space to clear the record and then close the form I get a runtime error.
Here is the before update code on the combo box. It checks to make sure the user does not assign a player to two teams. It works great except if the combo box is blank. Then I get an error.
Any thoughts on how I could intercept a Null value so I do not get that error message?
Private Sub cboPlayer_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("tfgTfgID", "t_TeamConfiguration", "tfgPlaID = " & _
Me.cboPlayer & " AND tfgTnaID <> " & [Forms]![f_TeamCfgChooser]![cboTeamName] & _
" AND tfgTnaID IN (SELECT tnaTnaID FROM t_TeamName " & _
"WHERE tnaSeaID = " & [Forms]![f_TeamCfgChooser]![cboSeason] & ")")) Then
MsgBox "You have already placed this player on another team " & _
"for the current season. Press ESC and enter new player."
Cancel = True
End If
End Sub
Thanks,
Speaking of Thanksgiving, I am thankful for this group.
Have a great Thanksgiving.
Bill
Reply via web post | Reply to sender | Reply to group | Start a New Topic | Messages in this topic (1) |
Tidak ada komentar:
Posting Komentar