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

    referencing subform entry in selection query

    Hi,
    I have a database for biological monitoring data of birds and mammals. The monitoring is done along line transects of 1000m, with 'point stations' every 200m (so 6 stations per transect).
    There is a table for the transects ('Transects') containing the following fields:
    'Transect ID', 'Transect name', etc...
    There is a separate table for the transect point stations ('Stations'), containing the fields:
    'Station ID', 'Transect ID' (referring to the Transect table).

    There is an overarching form ('Input sessions2') for data input info (date of input, etc.),
    in the first subform (Visit Info1) the visited transect is specified from a combo listing all possible transect ID from the Transects-table.
    In the sub-subform (Mammal observations), all observed mammals are entered. The station where it was observed, is selected from a combo (MobsTransect) listing all Station ID from the Stations-table.
    However, I want the choice of stations in the MobsTransect combo to be limited to the stations that are actually located on the transect specified in the first subform (Visit Info1)... in other words, only stations that have the specified transect as 'Transect ID' in the Stations-table should be selected.

    I used several methods to get this selection, but I assume I make the same mistake in all of them...

    the Row Source specified as follows:
    SELECT [Station ID] FROM Stations WHERE [Transect ID] = [Forms]![Input sessions2].[Visit Info1].Form![Transect] ORDER BY [Station ID];

    The sql looked as follows:
    SELECT Stations.[Station ID]
    FROM Stations
    WHERE (((Stations.[Transect ID])=[Forms]![Input sessions2].[Visit Info1].[Form]![Transect]))


    ORDER BY Stations.[Station ID];

    It keeps on asking to specify the parameter '[Forms]![Input sessions2].[Visit Info1].Form![Transect]', so I suppose the reference to the subform (Visit Info1) is not correct... but I can't figure out what is wrong..

    Any thoughts on this?

    (I tried to upload the empty database, but it's a complicated one and too big to send..)
    -

  2. #2
    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
    702
    If you look at the sub form's property sheet, what is the value in Name property? Note: This is different than the name of the form shown in the sub form control.

  3. #3
    Pielewuiter is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    11
    The value of the Name property for the subform is 'Visit Info1'...
    for the combo in the subform, it is 'Transect'

  4. #4
    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
    702
    I use this synatrax:

    Forms!MainformName!SubformControlName.Form!Control Name

    so try:

    Code:
     
    WHERE (((Stations.[Transect ID])=Forms![Input sessions2]![Visit Info1].Form![Transect]))
    What is the data type of Stations.[Transect ID]?

  5. #5
    Pielewuiter is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    11
    hm..
    I've tried to use your syntax... but still it prompts the same thing...
    the data time of Stations.[Transect ID] is Text
    seems not a very obvious problem...

  6. #6
    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
    702
    How are you using this SQL?

    Are you using it in VBA code to open a DAO or ADO recordset?

  7. #7
    Pielewuiter is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    11
    Due my rather limited skills in Access, I've build a query in design mode, and then switched to SQL mode to adjust it (because that makes more sense to me, although I'm not really any more skilled in SQL... :/). In the row source of the combo I refer to this query (named 'Query1').
    I'm not familiar with the terms of DAO or ADO recordsets... I suppose Access has a default for regular .mdb files?

  8. #8
    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
    702
    On what form is the combo box that is uing this query as the row source.

    If not on the form Input sessions2, is the form Input sessions2 open when you open the form with the combo box?

    I've build a query in design mode, and then switched to SQL mode to adjust it (because that makes more sense to me, although I'm not really any more skilled in SQL... :/).
    Interesting ...
    I am very skilled in reading/writing SQL statements. I could write ever query in notepad which is basically the same as SQL view. But I never do if I can avoid it. I really do prefer the Query Design mode. I only use the SQL view when I must. IMHO, the Query Designer Mode for most things can real make you a lot more efficient. This is one of major things I cover when training people to be Access Power Users or developers.

  9. #9
    Pielewuiter is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    11
    the combobox is on the sub-subform (called 'Mammal observations' - see first post), and so I suppose both the overarching form (Input sessions2) and the contained subform (Visit Info1 - that in turn contains the sub-subform) are all considered opened when I'm working on the sub-subform...?

    about the sql... it's just that I'm a real novice in Access, and I recently built a little background in programming (albeit Python)... so it feels more difficult to get to know the Access method - which is probably much easier once you know how it works - than to use the scripting logic...

  10. #10
    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
    702
    Did you get this figured out?

  11. #11
    Pielewuiter is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    11
    Hm no.. it's still not working.. the problem is I don't have very good internet connection and I don't have an Access 2007 manual at hand.

  12. #12
    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
    702
    Would it be possible to post a sample database that has the issue?

  13. #13
    Pielewuiter is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    11
    Here's the database...
    The overarching form is called 'Input sessions2'.
    The combobox that has the problem is located in the 'Mammal observation' sub-subform (caption='Station ID', name='Closest Transect Station'). The values in this combobox should be limited to the stations that are located on the Transect specified in the combobox (name='Transect', caption= 'Visited transect) on the subform 'Visit Info1'.
    I hope this makes sense once you've opened it...

  14. #14
    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
    702
    There is not a form with the object name of 'Input sessions2' in the navigation pane. Did you mean 'Input sessions'

  15. #15
    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
    702
    You are using the caption not the actual form name.

    Try changing:

    Code:
     
    [Forms]![Input sessions2].[Visit Info1].[Form]![Transect]
    to match the actaul form name like this

    Code:
     
    [Forms]![Input sessions].[Visit Info1].[Form]![Transect]

    You will also need to use the after update event for combo box control
    [Forms]![Ipout sessions].[Visit Info1].[Form]![Transect] to requiry the combo box located in the 'Mammal observation' sub-subform (caption='Station ID', name='Closest Transect Station').

Page 1 of 2 12 LastLast
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