Results 1 to 6 of 6
  1. #1
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544

    Need help with syntax please

    Database tracks group home residents medical information. Lots of fields and subforms. So I thought it would be cool to create a Quick Access form, where a user could choose the resident and the area they want to enter data for. I created a table that contains the name of the parent form, the child form, the short name and the abbreviation of the form that I use on the parent form to identify the subforms.



    For example:

    ParentForm Subform Shortname Abbr
    ResidentInformation ResidentDME/SuppliesSubform DME/Supplies RDME


    And my code successfully opens the correct form:
    Code:
    Private Sub FormList_AfterUpdate()
    Dim reqform As String
    Dim abbr As String
    
    reqform = Me.FormList.Column(1)
    abbr = Me.FormList.Column(3)
    
    DoCmd.OpenForm Me.FormList.Column(1), , , "residentid=" & Me.ResidentList.Column(0)
    
    Forms!quickaccess.FormList.Column(3).SetFocus
    
    End Sub
    Once the form is opened I want the focus to be set to the appropriate subform (the abbr), my latest attempt is the last line in my code above. I know it's totally wrong and I get the "object required" error. I don't want to put the set focus code in the "on open" event because the forms could be opened from several different places. Any thoughts? Is this even possible?

    TIA!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Never seen anything like this. Don't think I would do this.

    Is reqform supposed to hold name of parent form?

    Is abbr supposed to hold name of the subform container control?

    If yes to both:

    Forms(reqform).Controls(abbr).SetFocus
    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.

  3. #3
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Thank you June. Getting closer...still tweeking. Why wouldn't you do this?

  4. #4
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    This worked:
    Code:
    Forms(reqform).Controls(abbr).Visible = True

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Maybe I'm just lazy. Seems like an extra development step and I'm just not seeing any advantage gained with creating this table. Why not just reference names directly in the code?
    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.

  6. #6
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Quote Originally Posted by June7 View Post
    Maybe I'm just lazy. Seems like an extra development step and I'm just not seeing any advantage gained with creating this table. Why not just reference names directly in the code?
    Hmmm...I don't know. Guess it's just the way my brain works. Or doesn't work. ;-)

    Thanks for your help!

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

Similar Threads

  1. need help with syntax of SQL
    By vicsaccess in forum Programming
    Replies: 7
    Last Post: 04-12-2016, 03:23 PM
  2. Help with GUI Syntax and/or SQL
    By hellfire45 in forum Access
    Replies: 4
    Last Post: 04-01-2015, 12:55 PM
  3. Help with syntax
    By Gizmodo in forum Queries
    Replies: 4
    Last Post: 11-16-2012, 01:45 PM
  4. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM
  5. Please help SQL Syntax
    By jordanturner in forum Access
    Replies: 4
    Last Post: 09-02-2010, 08:05 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