View Full Version : Combo Box Not working


kapil0712
06-02-2008, 09:05 AM
Hello,
I have set up a combo box which shows up the values of training types.
If there is a training taken, then it has a specific date entered as well.
I would like to disable the combo box (Training Type) when there is a entry in the field Date Taken so that no one can change the training details. But when there is no data in the Date Taken field, I would like the combo box to be enabled so that I can edit the training type.

I tried the following code:
If DateTaken <> 0 Then
Form.SetFocus
CourseName.Enabled = True
Else
CourseName.Enabled =False

Forms![frmCurrentEmployeesKapil].DefaultEditing = 2

End If

Where my form name is CurrentEmployeesKapil.


Please let me know what should I do. I tried all sorts of combinations of codes but nothing seems to work. Also could you please tell me where to find the name of the combo box. I am sure I got the right name but it doesn't seem to work.


Thanks in advance
kapil

KenHigg
06-02-2008, 09:20 AM
Something like the following in the forms onCurrent event:


If me.DateTaken & "" = "" Then
me.CourseName.Enabled = True
Else
me.CourseName.Enabled =False
end if


???

kapil0712
06-02-2008, 09:37 AM
Thanks Ken,
I am sorry I am not very familiar with access. Could you please tell me where exactly to fit the code (Oncurrent event means?)
Also where to find the name of the combo box?

Thanks

KenHigg
06-02-2008, 09:47 AM
Both of these are in the properties window for the form and combo box.

kapil0712
06-02-2008, 11:39 AM
Thanks a lot again..but i am not able to find the the OnCurrent event..
I am able to find Onenter Onexit onclick and others..
What should I do? And the code is not working at the above mentioned places.
Thanks

boblarson
06-02-2008, 12:05 PM
Here's a Visual:
http://www.btabdevelopment.com/main/QuickTutorials/Wheretoputcodeforevents/tabid/56/Default.aspx

kapil0712
06-02-2008, 12:46 PM
Thanks Bob,
But I am still not getting the oncurrent event for the sub form. Attached alongwith is the example...
Could you please check whats the problem...I have the problem posted earlier.
Thanks a lot

boblarson
06-02-2008, 12:52 PM
It's going to be kind of hard without any of the tables.

kapil0712
06-02-2008, 01:03 PM
Bob attached is the complete list of tables. I am sorry there is no data in the tables since its against the institution policy.
Hope that will get some idea..
thanks bob

boblarson
06-02-2008, 01:18 PM
Okay - here's your revised sample.

A few things -

1. I put the employee ID text box on the main form just to verify that the subform had the right number

2. Your design is a bit out of sorts and I had to add a primary key to your tblTrainingDetails and modify a little around course to add a course ID. You really need some additional help in getting the right table design. Your relationships were a bit off too (I didn't really fix them, but you will want to).

If you have questions let me know. See attached to see it work (in the main/subform setup).

kapil0712
06-02-2008, 01:58 PM
Bob,
I didn't consider the path...i mean form name then sub form name then the event name.
after considering it, it did work..:):):)
thanks a lot...
kapil