Results 1 to 3 of 3
  1. #1
    TimW is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Posts
    2

    Query from a child record in a one to many form

    When I execute the following query in a subroutine called by a double click on a child record in a parent-child (one to many form) I get a Runtime error 3601. Too few parameters. Expected 1.

    Code:
            strSQLString = "SELECT Enquiry.Customer_Name, Enquiry.Rooms " & _
                           "FROM Enquiry " & _
                           "WHERE [Enquiry.Enquiry_Number] = " & Me.Enquiry_Number
            Set rs = CurrentDb.OpenRecordset(strSQLString)
    Enquiry is the Parent table and "Enquiry_Number " is the joining field (master key in the Parent table "Enquiry")

    So in fact I am trying to retrieve values from two fields in the parent table that are visible on the form (Customer_Name and Rooms) and I think this where the problem lies?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    are you sure 'Enquiry_Number' is the name of the text box? (not the field, tho they can be the same)
    did you put a stop on that line (F9) to see if it has a value?
    dd you see if the SQL string was legal? (again F9)

  3. #3
    TimW is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Posts
    2
    When I try F9 and Shift F9 I can see the query comes up with a Boolean value of false. It seems it is not picking the record up.

    I have some similar code immediately after this code that works fine, but it is querying a connected table that is not the parent of the form, see

    Code:
            strSQLString = "SELECT Hotels.Email, Hotels.Contact " & _
                           "FROM Hotels " & _
                           "WHERE [Hotels.Key] = " & Me.HotelKey
            Set rs = CurrentDb.OpenRecordset(strSQLString)
    So this is why I think the problem is something to do with the query being of the parent record of the form.

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

Similar Threads

  1. Replies: 7
    Last Post: 07-28-2015, 11:50 AM
  2. Replies: 1
    Last Post: 12-14-2014, 02:13 AM
  3. Child Record Created, but won't display in child form
    By CementCarver in forum Programming
    Replies: 1
    Last Post: 04-10-2013, 12:42 PM
  4. Child Form - Cannot Create Record
    By CementCarver in forum Programming
    Replies: 2
    Last Post: 04-04-2013, 05:41 PM
  5. Replies: 1
    Last Post: 11-21-2011, 07:52 PM

Tags for this Thread

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