Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    Jun 2003
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Focus (Access 2000)

    I have 2 buttons on a form, one button opens another form where you can edit the data, the 2nd opens that same form where you can just view the data

    when i open the one to edit the focus is up top, the second one every time i open it there is no focus and its halfway down the screen and i have to scroll up every time i use this button

    i didnt write the code i am attempting to fix this and i was wondering if there is a quick way to fix it?

    Thanks,
    Jordan

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Focus (Access 2000)

    Hi Jordan,

    Can you tell us how the distinction is made? Does the code behind the second button open the form with something like DoCmd.OpenForm "FormName", , , , acFormReadOnly, or is there code in the On Open or On Load event of the form being opened that set the form to editing or just viewing the data?

  3. #3
    3 Star Lounger
    Join Date
    Jun 2003
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Focus (Access 2000)

    It has DoCmd.OpenForm "Add_Pole_Line_Operations_Form"

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Focus (Access 2000)

    Thanks.

    You stated earlier that both buttons open the same form, but one of them opens it for editing, the other for viewing only. The code must tell the form some way or another that it has to allow editing or not. If the On Click event just opens the form, there must be code in the On Open or On Load event of Add_Pole_Line_Operations_Form that determines this. Please open Add_Pole_Line_Operations_Form in design view, and activate the Events tab of the Properties window. Most probably On Load or On Open (or both) contain "Event Procedure". Click the builder button ... to the right of "Event Procedure" and copy the code to a post. If the code is very long, paste it into a text file and attach that, instead of pasting the code into your reply.

  5. #5
    3 Star Lounger
    Join Date
    Jun 2003
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Focus (Access 2000)

    here it is Hans, Thanks for looking at it
    Attached Files Attached Files

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Focus (Access 2000)

    Jordan,

    The code in the On Load event procedure disables some of the controls on the form if you open it for viewing only:<pre> sap_order_no_text.Enabled = False
    Combo_Plant_Selection.Enabled = False
    Check_authority_Requested.Enabled = False
    Text_Appendix.Enabled = False
    Text_Pole_Number.Enabled = False
    Text_Location.Enabled = False
    Combo_Municipality.Enabled = False
    Text_reference_gain.Enabled = False
    Command_Save_PLO_Doc.Enabled = False
    Command_transfer_to_Admin.Enabled = False</pre>

    This causes Access to set focus to the first control that is not disabled; if this is lower down, it will cause the form to scroll. You could remedy this by locking one or all of these controls instead of disabling them. The downside of that is that users may become confused, because they are able to click in a control, but can't modify the contents. To lock instead of disable, replace .Enabled = False by .Locked = True; you can do this for a control in the list above that is near the top of the form, or for the whole list.

    There are some other tricks you could employ, but try this first.

  7. #7
    3 Star Lounger
    Join Date
    Jun 2003
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Focus (Access 2000)

    Perfect! Thanks Hans.

  8. #8
    3 Star Lounger
    Join Date
    Jun 2003
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Focus (Access 2000)

    hey, I also have a 3rd button on this form and it opens up that same form to add a new record , when it opens almost all of the boxes clear out, but some dont, what can i do to clear them all, i didnt know if you could tell by the attached code?

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Focus (Access 2000)

    Jordan,

    I don't know enough about the form from just looking at the code to be sure. There is only one control that is being set when the form is opened for adding a new record: Text_Current_Date is set to the current date.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •