A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Enable/Disable Control



 
 
Thread Tools Display Modes
  #1  
Old October 12th, 2009, 03:38 AM posted to microsoft.public.access.forms
alison.justice
external usenet poster
 
Posts: 40
Default Enable/Disable Control

I have a form that has a control named CategoryID, what I am trying to
accomplish is if the control has data in it then the data cannot be changed,
but if there is no data in the control then it is available so I could enter
information then once the data is entered it basically disable the control
how would I do this.

And on the property portion of the form is there an OnCurrent in Access 2007
I don't see it?
--
Alison
  #2  
Old October 12th, 2009, 04:29 AM posted to microsoft.public.access.forms
Arvin Meyer [MVP][_2_]
external usenet poster
 
Posts: 2,310
Default Enable/Disable Control

Yes there is a Current event. Use something like:

If Len(Me.txtControlName & vbNullString) = 1 Then
Me.txtControlName.Locked = True
Else
Me.txtControlName.Locked = False
End If
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Disclaimer: Any code or opinions are offered here as is. Some of that
code has been well tested for number of years. Some of it is untested
"aircode" typed directly into the post.

"alison.justice" wrote in message
...
I have a form that has a control named CategoryID, what I am trying to
accomplish is if the control has data in it then the data cannot be
changed,
but if there is no data in the control then it is available so I could
enter
information then once the data is entered it basically disable the control
how would I do this.

And on the property portion of the form is there an OnCurrent in Access
2007
I don't see it?
--
Alison



  #3  
Old October 12th, 2009, 04:31 AM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Enable/Disable Control

"alison.justice" wrote in message
...
I have a form that has a control named CategoryID, what I am trying to
accomplish is if the control has data in it then the data cannot be
changed,
but if there is no data in the control then it is available so I could
enter
information then once the data is entered it basically disable the control
how would I do this.

And on the property portion of the form is there an OnCurrent in Access
2007
I don't see it?



There certainly is. Are you looking at the Events tab of the property
sheet? Access 2007 did reorder some of the properties, IIRC, but it didn't
take away the Current event or the On Current property.

You're right to be thinking of the Current event. I'd use code like this
for the Current event:

'------ start of example code ------
Private Sub Form_Current()

Me.CategoryID.Enabled = IsNull(Me.CategoryID)

End Sub
'------ end of example code ------

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #4  
Old October 12th, 2009, 03:43 PM posted to microsoft.public.access.forms
alison.justice
external usenet poster
 
Posts: 40
Default Enable/Disable Control

Yes I was looking at the Event tab and did not see it listed, I'm using
Access 2007.

Thank you for the code, I tried to figure it out myself, but sometimes those
books don't help.

--
Alison


"Dirk Goldgar" wrote:

"alison.justice" wrote in message
...
I have a form that has a control named CategoryID, what I am trying to
accomplish is if the control has data in it then the data cannot be
changed,
but if there is no data in the control then it is available so I could
enter
information then once the data is entered it basically disable the control
how would I do this.

And on the property portion of the form is there an OnCurrent in Access
2007
I don't see it?



There certainly is. Are you looking at the Events tab of the property
sheet? Access 2007 did reorder some of the properties, IIRC, but it didn't
take away the Current event or the On Current property.

You're right to be thinking of the Current event. I'd use code like this
for the Current event:

'------ start of example code ------
Private Sub Form_Current()

Me.CategoryID.Enabled = IsNull(Me.CategoryID)

End Sub
'------ end of example code ------

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:13 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.