Results 1 to 9 of 9
  1. #1
    Kknopf is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2012
    Posts
    4

    Make Sub Form visible once date is entered

    I am attempting to create a sub form timesheet that is only visible after a date is entered in a the main form. The text box in the main form contains a date picker. When I attempt to create a code such as me.visible=false when loading and then me.visible=true when the date is chosen, I receive a run time error 2110. Is there a better way to hide the subform initially then make it visible once the date is chosen. I apologize if the question is unclear or basic, I am a newbie to Access and the forum. Any help would be greatly appreciated.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,522
    I do it from the main form, in the after update event of the control the user enters data into (your date):

    Me.frmTimeCardData.Visible = True
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Kknopf is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2012
    Posts
    4
    Thank you pbaldy for the response. I may not understand what you are referring to, so if I can clarify it might help me.
    I have a main form titled COE Weekly Timesheet that contains a user name field and a date picker field. The subform, which is titled COE Weekly Timesheet_Sub, is currently visible. I would like for the subform (COE Weekly Timesheet_Sub) to only be visible once the date picker field has been chosen. At this point I am getting a run time error that says it cannot set focus to the subform which I believe has to do with me setting the subform as not visible On Load. How would you suggest I load the code above to make it work properly. Thanks again for the help.

  4. #4
    caki2112 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    9
    When you refer to On Load, are you talking about the On Load property of the subform or the main form? If the subform, you actually need to use the main form's On Load property to make the subform invisible: [COE Weekly Timesheet_Sub].visible = false. (I may have the syntax wrong - I don't generally use names with spaces. I believe the brackets take care of that though.)

    Similarly, you would then want to put the code to make the subform visible on the After Update property of your date picker field.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,522
    I would make the subform not visible in design view, so it comes up hidden. Then put code similar to the above in the after update event of the date control. If you want to hide it in code, I'd use the load event of the main form, not the sub. If you're still stuck, can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Kknopf is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2012
    Posts
    4
    Again, thanks for the responses. I am still running into a run time error. I will go ahead and post the db. I was able to get the form to be not visible initially, but once the date is chosen, it produces the run time error..COE Weekly Timesheet.zipCOE Weekly Timesheet.zip the db should be posted, let me know if that is not the case.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,522
    The code to set focus to the subform in the employee combo will error if you do that first. Same with the change event of the week ending control. This works when I tab out of the date control after selecting:

    Code:
    Private Sub Week_Ending_AfterUpdate()
      Me.COE_Weekly_Timesheet_Sub.Visible = True
      Me.COE_Weekly_Timesheet_Sub.SetFocus
    End Sub
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    Kknopf is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2012
    Posts
    4
    Quote Originally Posted by pbaldy View Post
    The code to set focus to the subform in the employee combo will error if you do that first. Same with the change event of the week ending control. This works when I tab out of the date control after selecting:

    Code:
    Private Sub Week_Ending_AfterUpdate()
      Me.COE_Weekly_Timesheet_Sub.Visible = True
      Me.COE_Weekly_Timesheet_Sub.SetFocus
    End Sub
    Sorry for the delay. That worked perfectly. Thank you.

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,522
    Happy to help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 5
    Last Post: 08-13-2012, 06:57 AM
  2. make fields visible onclick() button
    By rivereridanus in forum Programming
    Replies: 4
    Last Post: 06-25-2012, 11:08 PM
  3. Replies: 3
    Last Post: 03-29-2012, 12:40 PM
  4. Replies: 2
    Last Post: 01-06-2011, 04:38 AM
  5. Replies: 10
    Last Post: 12-31-2010, 12:35 PM

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