Code to disable text boxes for entry depending on combobox selection

tot'

New member
Local time
Today, 21:04
Joined
May 8, 2008
Messages
4
i need and please pardon me for my lack of experience in access and vba.

I need to write a code that will disable some text boxes depending on combobox selection. I have a form called hardware and then on the same form i have a combobox that has the options for all the hardware.The code should be such that when i select "printer" for example all the entries that are not relevant for the printer should be disables/not made active.

hope this is clear.thanks in advance
 
put something like this in the Afterupdate event of the combobox:
Code:
If combobox.value = 'printers' then    
    txtbox1.enabled = false
    txtbox2.enabled = false
end if
don't forget to re-enabled them when you need them.

HTH,
Chris
 
The code did work for the first option of the combobox which is the Printer. But when i try to add the code for other options it pulls an error.

just for clarity this is the code that i wrote:

If HardwareType.Value = "Printer" Then
HardDiskSize.Enabled = False
MonitorMake.Enabled = False
RAMSize.Enabled = False
OS.Enabled = False
MonitorSerialNumber.Enabled = False
ProcessorSpeed.Enabled = False

Else
HardwareType.Value = "Copier" Then
EmployeeFirstName.Enabled = False
EmployeeLastName.Enabled = False
HardDiskSize.Enabled = False
ProcessorSpeed.Enabled = False
OS.Enabled = False
ConnectionType.Enabled = False
MonitorMake.Enabled = False
MonitorSerialNumber.Enabled = False
RAMSize.Enabled = False
End If

Up to the end of the printer code it did disable all those textboxes but the problem arises when i try for the copier option.
 
HardwareType.Value = "Copier" Then

A line like that doesnt work... You are doing something IF... then you have to include the IF.

IF HardwareType.Value = "Copier" Then

also you have to put an "end if" at the end or each IF you start, or you will get another error.

If the options are Copier OR Printer (i.e. no third option) then there is no need to do the second if.
 
thank you soo.. much, everything is perfect now. Thanks
 

Users who are viewing this thread

Back
Top Bottom