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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|