Repost re Securing a Combo Box

  • Thread starter Thread starter Leon
  • Start date Start date
L

Leon

Hi. I posted this on 15th Oct but had no replies. Thought
Id give it one more go. Thanks.

Im using Access 2002 on XP. Is it possible for Access
to be made to recognise when a combo box selection has
been made for the first time and produce a message box
when subsequent selections are attempted, to guard
against inadvertant changes being made?

I want users to be able to select from the combo box
list, the first time, as normal. On the next and
subsequent selection attempts in the same combo, I would
like to arrange for a message box (or better, a form of
my own design) to pop up with text like - You Are About
To Change The Current Selection, to Continue Select
Continue, otherwise select Cancel. There would be
Continue and Cancel buttons for them to use.

Is this possible? Thanks, Leon
 
Why don't you address it from a different angle? Instead of
looking to see if the combo has been used, why not check to
see if the combo's field contains a value? If it's new it
won't, if there's something in there you want the warning
message.
 
Thanks for this Nick. Yes I see what you mean - I hadn't
thought of doing it that way. The trouble is, Im not
really very clever at building Event Code. Can you, or
anyone else, help me with that bit please? The combo name
is cboSchoolName. What would the code look like and what
Event should I put it in? I would want to bring up the
warning message at the point when the user opens the
combo (ie clicks on the combos little down arrow on the
right hand side). Also, presumably the message box will
just allow me to warn the user and will have an OK button
to close the message? That would be OK. Thanks, in
advance for any further help you can give me. Leon
 
This ought to get you started:

'*******************
Private Sub cmbSchoolName_BeforeUpdate(Cancel As Integer)

Dim varWas As Variant, varNow As Variant

varNow = Me.cmbSchoolName
varWas = Me.cmbSchoolName.OldValue

If varNow <> varWas Then
MsgBox "I've changed"
If varWas <> "" Or Not IsNull(varWas) Then
MsgBox "I wasn't empty before so set me back to what I
was"
Cancel = True
Me.cmbSchoolName.Undo
End If
Else
MsgBox "I AM THE SAME"
End If

End Sub
'**************************

--
Nick Coe (UK)
AccHelp v1.01 Application Help File Builder
http://www.alphacos.co.uk/
Download Free Demo Copy
----
 
Back
Top