Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    Pielewuiter is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    11
    Hi!


    it seems I'm not familiar enough with basic Access terminology, because I misunderstood the term 'Control' in your questions... Sorry for that. They make me run here, before I can walk...
    Your solution worked.. the combo box list is restricted to the stations on the selected transect. Thank you very much for your help.
    Now, next... the After update event...
    I've tried the following (which I adapted from an example in the Access help files):

    Code:
    Private Sub Transect_AfterUpdate()
    
    Dim ctlCombo As Control
    
        ' Return Control object pointing to a combo box.
        Set ctlCombo = Forms![Input sessions]![Visit Info1]![Mammal observations].Form![Closest Transect Station]
    
        ' Requery source of data for list box.
        ctlCombo.Requery
        
    End Sub
    But it gives the error 'The field Mammal observations that is being referred at in the expression could not be found' (or something similar - translation from dutch here)...

    so again a referencing problem?

  2. #17
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    705
    I have always avoided using a sub form on a sub form. I normally always have my sub forms in continuous mode.


    This works in your exanmple:
    Code:
     
     
    Private Sub Transect_AfterUpdate()
     
    Me.[Mammal observations1].Form![Closest Transect Station].Requery
    
    End Sub
    Boyd Trimmell aka Hitechcoach
    Database Architect and Problem Solver
    Microsoft MVP - Access Expert
    25+ years specializing in Accounting, Inventory, and CRM systems
    "If technology doesn't work for people, then it doesn't work."

  3. #18
    Pielewuiter is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    11
    Thanks very much again HiTechCoach! Your help is very much appreciated. I think I'm exactly where I want to be with the database. There's only one more small thing I haven't been able to figure out...
    Besides the mammal observations, there's a subform for the birds observations as well.. I assumed it was straightforward and I could just add a line to the VBA to have it update the bird transect stations as well. As far as I can tell it is just another subform under the Visit Info form, right?
    However I got the error:
    'The field | that is being referred to in the expression could not be found'..

    Code:
    Private Sub Transect_AfterUpdate()
    
    Me.[Mammal observations1].Form![Closest Transect Station].Requery
    Me.[Bird observations1].Form![Station ID].Requery
        
    End Sub

  4. #19
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    705
    First I change the rowsource of the [Station ID] combo box to be the same as the [Closest Transect Station] combo box.

    This worked for me:

    Code:
    Private Sub Transect_AfterUpdate()
       Me.[Mammal observations1].Form![Closest Transect Station].Requery
     
       Me.[Bird observations].Form![Station ID].Requery
    End Sub
    Boyd Trimmell aka Hitechcoach
    Database Architect and Problem Solver
    Microsoft MVP - Access Expert
    25+ years specializing in Accounting, Inventory, and CRM systems
    "If technology doesn't work for people, then it doesn't work."

  5. #20
    Pielewuiter is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    11
    Ha, I had the row source of the combo box in the bird form set, so that couldn't be the problem... The only thing different between our solutions seems to be the naming of 'Bird observations'... (spacing and blank lines didn't really matter when I tried it). I don't really get why it needs to be 'Mammal observations1' for the mammal form, and just 'Bird observations' for the bird from...
    but, ok... it works! I got it the way I wanted it!
    So again, a big thank you for your time and help!
    This topic can be closed as far as i'm concerned (although, if you feel like unpuzzling me on the name issue, go ahead!
    cheers!
    Maarten

  6. #21
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    705
    You are getting the form name and the sub form control name confused.

    I do not like to use the default naming that Access automatically assigns to objects. It has been my experience that this can get very confusing to people. As you have experienced.

    You were not using the sub form control name but the actual form name used in the sub form control

    Generically the syntax is:
    Code:
    Me.[SubForm_Control_Name].Form![ComboBox_Control_Name ].Requery

    When I was writing this code for you I went to the properly sheet for each the object to the name property and copied and pasted it into the code. This way I am sure I have the correct name.


    When it comes to naming conventions, the most important one is the one you use consistently. I started Windows programming with with VB4 and Access 2.0. I took the naming conventions I have used for years prior to Windows programming and expanded it ti handle the new objects. I basically have been using the same naming style for almost 30 years.

    I have a good example on my site. See:
    Access Naming Conventions
    Boyd Trimmell aka Hitechcoach
    Database Architect and Problem Solver
    Microsoft MVP - Access Expert
    25+ years specializing in Accounting, Inventory, and CRM systems
    "If technology doesn't work for people, then it doesn't work."

  7. #22
    Pielewuiter is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    11
    Thanks for explaining. I think I do understand the difference between the sub form control name and the form name used in the sub form control... the autonaming is probably useful for many, most of the time...

    Maarten

  8. #23
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    705
    Quote Originally Posted by Pielewuiter View Post
    ...the autonaming is probably useful for many, most of the time...
    Maarten,

    I would have to disagree. The auto naming is the cause of many issues. Especially with reports. The auto generated names are either meaningless (example: Text1) or a duplicate of other ejects (control name and field name the same). This makes debugging more difficult when there is a problem. It makes documenting a database more time consuming. Etc., and etc.

    The good thing about autonaming is that it does get me more hours of billable time repairing what it does.
    Boyd Trimmell aka Hitechcoach
    Database Architect and Problem Solver
    Microsoft MVP - Access Expert
    25+ years specializing in Accounting, Inventory, and CRM systems
    "If technology doesn't work for people, then it doesn't work."

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 10-06-2010, 07:28 PM
  2. Subform Selection
    By doug adams in forum Forms
    Replies: 2
    Last Post: 06-28-2009, 10:27 PM
  3. Entry into subform
    By lynchoftawa in forum Forms
    Replies: 1
    Last Post: 06-17-2009, 09:28 AM
  4. Subform Data Entry Issue
    By yuriyl in forum Forms
    Replies: 3
    Last Post: 05-14-2009, 08:49 PM
  5. Report Detail Entry Selection Problem
    By Joe in forum Reports
    Replies: 0
    Last Post: 02-02-2009, 06:55 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