Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    330
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Reading subform data (Access 2003 winxp sp2)

    I have a form with a subform that shows (of course) filtered related records. I am trying to write code that will read the records from the subform so I can assemble the data into a string to export to word. I already have the export to word part all set up and running. The subform is the new bit on the form and I just need to access the info on it.

    I have tried opening a recordset on the subform table and filtering it by the parent field value from the main form but I keep getting weird errors. Is there another way to do it?
    "Heading for the deep end"

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Reading subform data (Access 2003 winxp sp2)

    You can use the RecordsetClone property of the subform to return a recordset object that represents the data currently displayed in the subform.

    Dim rst As DAO.Recordset
    Set rst = Me.NameOfSubform.Form.RecordsetClone

  3. #3
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    330
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Re: Reading subform data (Access 2003 winxp sp2)

    Thanks Hans,

    Just what I needed.

    Happy Christmas!
    "Heading for the deep end"

  4. #4
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    330
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Re: Reading subform data (Access 2003 winxp sp2)

    I need some more help.

    My quoting form and subform open ok and all fields are editable.
    When I press the create quote button, all the data is collected properly (almost, the save cmd causes a 2501 error), the word document is created and the fields are correctly filled and the document saved.

    My trouble now begins

    When I go back to the quote form, the fields in the subform seem to be locked and I cannot move to the next form.
    Fields on the main form are able to be edited but I'm not sure if it is saved correctly because
    When I try to close the form, it pops up a box saying "You can't save this record at this time....yada yada yada"

    here is the code for the button: see attachment

    The coding for the word document came from an example by Helen Feddema

    Can you see why the subform is locking up and why the savecommand causes an error now but works fine in the original form? (which is the same thing just without the subform recordsetclone code snippet)

    Many thanks for all help.
    Attached Files Attached Files
    "Heading for the deep end"

  5. #5
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    330
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Re: Reading subform data (Access 2003 winxp sp2)

    for greater clarification, here is a sample db with the offending form in it

    http://www.shute-eng.com.au/SampleDB.zip
    "Heading for the deep end"

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Reading subform data (Access 2003 winxp sp2)

    1) If you had taken the trouble to compact the database, the zip file with the database and template is less than 100 KB so it could have been attached to a post.
    2) Your code refers to an undefined function NetUser.
    3) You open a recordset that doesn't allow the use of FindFirst, but since you have On Error Resume Next you don't receive an error message. You should use

    Set rst = CurrentDb.OpenRecordset("tblDbPaths", dbOpenDynaset)

    etc.

    4) Right at the beginning of the On Click event procedure, you modify the record in the main form:

    [QPrice] = txtQPrice.Value

    But for some reason the record cannot be saved after that. Even if you exit the procedure after this line, the form is "frozen". So you'll have to remove that line.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •