Results 1 to 6 of 6
  1. #1
    Access_Novice is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Posts
    265

    How to use the BorderStyle property of a form

    I have this code in the Open Event of a form:



    Private Sub Form_Open(Cancel As Integer)

    Me.BorderStyle = 1

    End Sub


    I get the error: To set this property open the form in Design View. I know this is only applicable in form view but I am in design view. Here are the steps I took:

    1. I opened the form by double clicking it. I am in Form View.
    2. I switched to Design view
    3. I added the code above to the Open Event.
    4. I came back to the form (still in Design View) and I attempt to change it to Form View so I can see how this works. Then I get the error.

    So I was in Design View before I entered this code. What am I doing wrong?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Some properties can not be set using VBA and some can not be set when the form is loading or being opened. Use the properties window in design view or whatever the properties thing is called.

    edit: property sheet

  3. #3
    Access_Novice is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Posts
    265
    Quote Originally Posted by ItsMe View Post
    Some properties can not be set using VBA and some can not be set when the form is loading or being opened. Use the properties window in design view or whatever the properties thing is called.

    edit: property sheet
    That's helpful to know. I would have thought that you can use any property at any time. Actually, I did go through the property sheet to the Open Event in order to add my code. Since I am just starting Access, I'm just trying to find the best way to learn programming Access. Do you have any ideas on how I should approach this?

    Right now, I am on that MS website, looking at the forms object, and going thru the properties of the form object.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    You wrote the code in Design view but the procedure executes when the form opens in Form (or Continuous or Datasheet) view.

    What you encountered is a run-time error.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Access_Novice is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Posts
    265
    Quote Originally Posted by June7 View Post
    You wrote the code in Design view but the procedure executes when the form opens in Form (or Continuous or Datasheet) view.

    What you encountered is a run-time error.
    But you're supposed to open the form in form view in order to see the results right? What about these:

    Private Sub Form_Open(Cancel As Integer)
    'Me.BorderStyle = Dialog
    'Me.BorderStyle = "Dialog"
    Me.BorderStyle = 3
    End Sub

    None of these three worked. I did this in design view, then I was prompted to close the form. Then I opened it and received an error message.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    As stated, some properties cannot be changed programmatically during run time.

    Code could open the form in Design View, modify the property, save the form with the design change then open in Form view with the new property setting - unless the db were published as an executable. Executable version of db cannot have design changes.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How do you use an event property for a form?
    By Access_Novice in forum Programming
    Replies: 6
    Last Post: 12-31-2013, 02:46 AM
  2. RecordSource Property of a form
    By mkc80 in forum Access
    Replies: 4
    Last Post: 08-11-2012, 05:43 PM
  3. Replies: 3
    Last Post: 07-20-2012, 11:41 AM
  4. Replies: 0
    Last Post: 03-30-2012, 12:24 PM
  5. Property Managment Form
    By JennyHunt in forum Forms
    Replies: 0
    Last Post: 03-02-2011, 08:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums