View Full Version : Limiting user error


D B Lawson
01-21-2000, 02:08 PM
I have a subform in datasheet view in which the user has to select an issue from a combo box. They then have to categorise the issue by selecting M, A or SO, through a list box. They are only allowed one M issue per entry but can have multipal A or SO entries. Is there anyway of stopping them entering M more than once? The issues subform is linked to the main form by a reference number.

Hope this is clear.

Travis
01-23-2000, 08:46 PM
Try this:

On the subform

on the BeforeUpdate of the 'categorise the issue' Field add this code.

Private Sub Categorise_The_Issue_BeforeUpdate(Cancel as Integer)
dim rst as recordset
if me.recordsetclone.RecordCount<>0 then
set rst = me.RecordsetClone
rst.moveFirst
do while not rst.EOF
if rst.Fields("CategoriseTheIssue") = "M" then
msgbox "You have already used M."
Cancel = True
me.[Catergorise_The_Issue].Undo
Exit Sub
end if
rst.movenext
Loop
set rst = nothing
End if

End Sub

D B Lawson
01-24-2000, 12:36 AM
Thanks, this is working in part. However, once I select "M" once, it is then stopping me from selecting either "A" of "SO" for subsequent issues and categories relevant to the same recordset.

What else would I need to add?

[This message has been edited by D B Lawson (edited 01-25-2000).]

[This message has been edited by D B Lawson (edited 01-25-2000).]