Enable - Disable Field in Subform

ccondran08

Registered User.
Local time
Tomorrow, 00:43
Joined
Feb 27, 2014
Messages
58
Hi, looking for some help here please. I have a main form which has a subform and in the 'On Load' event it checks that the user's name (ENVIRON) is in a table as a security measure. If the user's name isn't in the table then one particular column is disabled so the user can not access the column.

Then I have two text boxes (txtUserNameLookup and txtUserNameLookupResult) on the main form which one of them is linked to a field in the subform (=[qry_Actions subform].[Form]![Owner]). Each time the user clicks on a different record then txtUserNameLookup will display the text of the what is in the field "Owner". I want to perform an action if and when the two textboxes are equal. I have the following code below which works fine in the 'On Load' event but if I change it to the 'After Update' event in the textbox linked to the field in the subform (txtUserNameLookup) then nothing happens. :banghead:


If Me.txtUserNameLookup.Value = Me.txtUserNameLookupResult.Value Then
Forms![frm_Actions]![qry_Actions subform]![Combo38].Enabled = True
Else
Forms![frm_Actions]![qry_Actions subform]![Combo38].Enabled = False
End If
Forms![frm_Actions]![qry_Actions subform].Requery
 
use your forms current event, and paste your code there. disable the error handling, since by the time your form open there is no current record yet.
 
Still not working. If I attached a button to the main form and paste in the code mentioned above then it works fine. Would like this to automatically activate after a different record is selected. I've tried to copy this under the 'After Upate', 'On Change' and 'On Lostfocus' but doesn't do anything. Is there something I need to do inside the subform ?
 
you have wrong reference to the combobox:

Forms![frm_Actions]![qry_Actions subform]![Combo38].Enabled = True

should be:


Forms![frm_Actions]![qry_Actions subform].Form![Combo38].Enabled = True
 
Sorry still not working. As I mentioned it works fine when I attach it to a button. I tried calling the button 'After Update' but still nothing. Any other suggestions, maybe creating a function in a module ?
 
does your code run on the subform event?
 
.. I tried calling the button 'After Update' but still nothing..
The 'After Update' event is only triggered if you've edit the data in the control.
Post a stripped down version of your database with some sample data, (zip it).
 
Thanks anyway guys, I've worked around this and come up with something else.
 

Users who are viewing this thread

Back
Top Bottom