Hi, Charles.
how could I ensure only one
customer could be set?
Use an update query to reset any other choices to false whenever the current
choice is chosen. In the following example, a bound form is used to make the
selection of the winner. The Boolean field for the winner selection is named
"Choice," chkChoice is a check box displaying this value, ID is the numerical
primary key of the table, and txtID is the name of the text box displaying
the primary key.
' * * * * Start Code * * * *
Private Sub chkChoice_BeforeUpdate(Cancel As Integer)
On Error GoTo ErrHandler
Dim sqlStmt As String
sqlStmt = "UPDATE " & Me.RecordSource & _
" SET Choice = " & False & _
" WHERE (ID <> " & Me!txtID.Value & ")"
CurrentDb().Execute sqlStmt, dbFailOnError
Exit Sub
ErrHandler:
MsgBox "Error in chkChoice_BeforeUpdate( )." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear
End Sub
' * * * * End Code * * * *
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. Remember that questions
answered the quickest are often from those who have a history of rewarding
the contributors who have taken the time to answer questions correctly.