×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Run-time error 2186

Run-time error 2186

Run-time error 2186

(OP)
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

RE: Run-time error 2186

which line in the code is it erroring out on?

RE: Run-time error 2186

(OP)
Hi jimbOne,

Thank you for the reply.

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

ctl.Value = null


Thanks,

REF

RE: Run-time error 2186

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.

RE: Run-time error 2186

(OP)
Thank you jimbOne. I will try your suggestions and get back to you with the results

RE: Run-time error 2186

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

RE: Run-time error 2186

(OP)
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

RE: Run-time error 2186

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.

RE: Run-time error 2186

(OP)
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

RE: Run-time error 2186

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.

RE: Run-time error 2186

(OP)
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

RE: Run-time error 2186

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

RE: Run-time error 2186

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close