Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Activate & Deactivate fields

Status
Not open for further replies.

ISDleftovers

Technical User
Dec 18, 2000
6
0
0
AU
I am new to programming 'dynamic' forms in that in the past to make a form that allows me to search one group of records I would make a form, and for a second group of records a separate form, and to search both groups of records, I would create a third form.
but realising the pain this could create for me when maintaining the system myself I have opted to create one form, and disable/deactivate the fields that are not required, while opening the form.

my problem is that some of the fields have a syntax different to others, which does not want to work for me. I worked out how to disable some fields, but the other fields have an "Item" keyword in their definition, this keyword gives an error whenever I test the code.

here is my code...
frmReport.fldAccName.Enabled = False
frmReport.fldAccName.BackColor = (ColorConstants.vbBlack)
'frmReport.fldOriginCity.Item.Enabled = False
'frmReport.fldOriginCity.Item.BackColor = (ColorConstants.vbBlack)
'frmReport.fldDestinCity.Item.Enabled = False
'frmReport.fldDestinCity.Item.BackColor = (ColorConstants.vbBlack)

the lines which I have commented out are the lines which give errors when run, ordinarily an "Argument not Optional" error, if anyone knows what is causing this or even just how to stop it I would greatly appreciate your help as there quite a few controls which will end up using this method.
 
Usually, the "Argument not Optional" error is caused by not passing an argument when a sub/function/object etc is expecting one. for example

Sub ProcA (Parm1 as integer, Parm2 as integer)

and in my code I call the sub like: ProcA(1) <===missing the 2nd argument

so to avoid this error you would alter the procedure's definition to:

sub ProcA (Parm1 as integer, Optional Parm2 as integer)

In your procedure you would include an: if IsMissing(Parm2) then statement to deal
with this possibility which in your case would be to disable the unused controls.

Have a good one!
BK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top