enable/disable from a combo box?

  • Thread starter Thread starter djkenny
  • Start date Start date
D

djkenny

Guest
hello, im very new to access and am starting a new project...

1 combo box: "ExamOrCwk" // Exam;Coursework

field1: "DateDue" // this field needs to be enabled only if "coursework" is selected from the combo box, and disabled if exam is selcted or field is left blank

field2: "ExamDate" // almost same as before.. this field should be enabled only if exam is selcted and disabled if coursework is selcted or the field is left blank

this is the code i was using:
Private Sub ExamOrCwk_Change()
If [ExamOrCwk] = "Coursework" Then [ExamDate].Enabled = "False"
If [ExamOrCwk] = "Examination" Then [ExamDate].Enabled = "True"
End Sub


i keep getting errors but am unsure what to do with it :confused:
id appreciate any help anybody could give

thanks in advance!
 
Place the code on the After_Update event, rather than the Change event.
 
And use a SELECT CASE structure.
 
Also, may I suggest, not enclosing True/False in quotes.

Whilst it will work, it means
a) more typing for you

and

b) harder to spot typing errors
e.g. my slysdexic fingers regularly produce "flase" and "ture" which if enclosed in quotes would compile, (but produce a Type Mismatch run-time error if executed) whereas if not enclosed in quotes (assuming Option Explicit is employed) will not compile - (Variable not defined - assuming you don't define flase or ture as variables) leading to earlier detection of such a mistake.

Happy Coding.
 

Users who are viewing this thread

Back
Top Bottom