combo box locked

M

mino

I kindly ask you a question.
I have a form with many controls and one of them is a combo box.
How can I do, once I have chosen from the drop-down menu, no longer able to change it (lock). thanks
 
J

John W. Vinson

I kindly ask you a question.
I have a form with many controls and one of them is a combo box.
How can I do, once I have chosen from the drop-down menu, no longer able to change it (lock). thanks

That's A VERY BAD IDEA unless your users never, ever make mistakes, and never,
ever use a touchy mouse; but if you really want to antagonize your users in
this way, set the combo's Enabled property to No in its AfterUpdate event.
Also set it in the form's Current event:

Private Sub Form_Current()
Me!combobox.Enable = IsNull(Me!combobox)
End If

But seriously: don't. Perhaps you could explain what real-life problem you're
trying to solve, there's got to be a better way.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 
M

mino

Il giorno giovedì 1 novembre 2012 01:51:30 UTC+1, John W. Vinson ha scritto:
That's A VERY BAD IDEA unless your users never, ever make mistakes, and never,

ever use a touchy mouse; but if you really want to antagonize your users in

this way, set the combo's Enabled property to No in its AfterUpdate event..

Also set it in the form's Current event:



Private Sub Form_Current()

Me!combobox.Enable = IsNull(Me!combobox)

End If



But seriously: don't. Perhaps you could explain what real-life problem you're

trying to solve, there's got to be a better way.

--



John W. Vinson [MVP]

Microsoft's replacements for these newsgroups:

http://social.msdn.microsoft.com/Forums/en-US/accessdev/

http://social.answers.microsoft.com/Forums/en-US/addbuz/

and see also http://www.utteraccess.com

Thank for ansewering.
I'm sorry but i find difficulty in explaining the real problem becouse I,m italian.But I try to do it again.
Since this database is used by many guys ,If someone changes the combo box value, since I have a statistical report generated upon that value, it willbe untruthful.So you can undestand how many important it's for me no-one must have the possibility to change that value after I save it(maybe before me warned with a msgbox). I hope to give a more idea.
 
J

John W. Vinson

I'm sorry but i find difficulty in explaining the real problem becouse I,m italian.But I try to do it again.
Since this database is used by many guys ,If someone changes the combo box value, since I have a statistical report generated upon that value, it will be untruthful.So you can undestand how many important it's for me no-one must have the possibility to change that value after I save it(maybe before me warned with a msgbox). I hope to give a more idea.

Set the combo box's Limit to List property to Yes to allow the user to only
select a value that you permit.

If that's not the problem, you can put a command button on the form to Accept
the record, and lock it from further changes. This would have code like:

Private Sub cmdAccept_Click()
Dim strMsg As String
Dim iAns As Integer
strMsg = "Accettare questo disco e impedire che cambiare in futuro?"
iAns = MsgBox(strMsg, vbYesNo)
If iAns = vbNo Then
Exit Sub
Else
Me.Dirty = False ' write the record to disk
Me.comboboxname.Enabled = False
End If
End Sub

Then in the form's Current event, lock the combo box if a value was previously
selected for the field:

Private Sub Form_Current()
Me.Comboboxname.Enabled = IsNull(Me.Comboboxname)
End Sub
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 
M

mino

Il giorno venerdì 2 novembre 2012 05:47:38 UTC+1, John W. Vinson ha scritto:
Set the combo box's Limit to List property to Yes to allow the user to only

select a value that you permit.



If that's not the problem, you can put a command button on the form to Accept

the record, and lock it from further changes. This would have code like:



Private Sub cmdAccept_Click()

Dim strMsg As String

Dim iAns As Integer

strMsg = "Accettare questo disco e impedire che cambiare in futuro?"

iAns = MsgBox(strMsg, vbYesNo)

If iAns = vbNo Then

Exit Sub

Else

Me.Dirty = False ' write the record to disk

Me.comboboxname.Enabled = False

End If

End Sub



Then in the form's Current event, lock the combo box if a value was previously

selected for the field:



Private Sub Form_Current()

Me.Comboboxname.Enabled = IsNull(Me.Comboboxname)

End Sub

--



John W. Vinson [MVP]

Microsoft's replacements for these newsgroups:

http://social.msdn.microsoft.com/Forums/en-US/accessdev/

http://social.answers.microsoft.com/Forums/en-US/addbuz/

and see also http://www.utteraccess.com

Mr.Vinson, I'm grateful for your help.The second option is that I was looking for.I hope to listen you again , by from Italy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top