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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-time error 2186

Status
Not open for further replies.

incagold

Programmer
Mar 21, 2003
54
Hi All,

Newbie is back with another question. We have a sub routine (code below) which we would like to assign visible and value (null) properties to the controls on a form. We need to be able to make some visible while others need to remain visible. <i> determines which ones will be visible. We also need to have all values set to null. All controls are unbound. When we run the code we get the error message:

Run-time error '2186' This property isn't available in
Design View

What are we doing wrong? Any help would be greatly appreciated and please accept our thans in advance.


Sub SetTextBoxProperties(i As Integer)

Dim frm As Form
Dim ctl As Control

Set frm = Application.Forms("frm_ADD")
'*** Enumerate Controls collection.
For Each ctl In frm.Controls
Select Case ctl.ControlType
'*** Check to see if control is text box.
Case acTextBox:
ctl.Value = null
If Val(Right(ctl.Name, 1)) > i Then
ctl.Visible = False
End If
'*** Check to see if control is combo box.
Case acComboBox:
ctl.Value = Null
'*** Check to see if control is check box.
Case acCheckBox:
ctl.Value = 0
End Select
Next ctl
End Sub


REF
 
Hi jimbOne,

Thank you for the reply.

The error occurs at the line where we want to assign null

ctl.Value = null


Thanks,

REF
 
when you open the form are you using the docmd.openform action? if so you should ensure that the second argument of the openform command is acNormal and not acDesign. If this error is happening at runtime consider placing a debug.print with the name of the control before the line that is erroring out, this could identify which control the problem is happening on. let me know what you find out.
 
Thank you jimbOne. I will try your suggestions and get back to you with the results
 
If error on this case, try this:
Case acComboBox:
ctl.ListIndex = -1

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Thanks jimbOne for the reply. Sorry for the delay, had to leave early.

The error message occurs immediately with the first text box. The form is activated from a switchboard's On Click event (=OpenForms("frm_ADD")

Thank you PHV for responding.

I will try your suggestion if I get an error on the combo box(es). Hopefully a resolution at the text boxes will solve my problem.

Appreciate your continued help guys. Being relatively new to this, I really don't know where to go next.

REF
 
well if the problem is occurring on the first textbox I would check to ensure that the textbox for which you are trying to change the .value property is not bound to a field in the underlying table/query, if it is you can't edit the .value property, you'll have to edit the underlying tables field which is associated with the textbox. let me know if this is the case.
 
Hi jimbOne,

Sorry for the slow response, was sent on the road.

I have checked the form and all the text, combo, and check boxes are unbound. There is a module activated from a command button that updates tables based on the values in the form's boxes.

Any other thoughts or suggestions? They are greatly appreciated.

REF
 
if you'd like you can try sending me the DB, or a test db with the problem recreated and I can have a look at it. jtseleie@theedge.ca Just make sure to zip it or my isp will block the attachment. it sounds like its something simple, I'm just not entirely sure where to begin looking other than what I've suggested.
 
Hi jimbOne,

Sorry for the long delay in response. Was sent on the road for an extended period. Just got back to my problem. I cannot send you the db as this is a government application and the information contained in it is classified. I will try to make a test db and e-mail to you. Thanks again for your help and let me apologize again for the delay in getting back to you.

REF
 
Hope you dont mind me butting in but

Set frm = Application.Forms("frm_ADD")
'*** Enumerate Controls collection.
For Each ctl In frm.Controls


Hope this helps
Hymn
 
Hi jimbOne,

Don't know what happened but when I built the example db everything worked fine. I copied this code back to my primary db and now it works fine. I am sending a copy of the test db to your e-mail just for your viewing pleasure. Thank you so much again for all your help and your patience. I sincerely appreciate it.

Hi hymn,

Thank you for your response. I appreciate you taking the time and interest to reply. The problem seems to have corrected itself(???). Everything works fine now.

REF

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top