Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by Minty View Post
    The Form_xx version will create an new instance of the form if I remember correctly. (I didn't know this it was pointed out to me in a thread on another forum here: https://www.access-programmers.co.uk...9/post-1747913)

    Also, assuming your code is in the parent form, if you were to refer to the subform container form the Main form using Me.MySubformControl.Form .... It would always be referencing the correct instance.
    Yes, that seems to be what was happening. Thank you for the link - this is something new to me and I need to read up on it thoroughly.

    I set the object variables with this in the Load event of the parent form:
    Code:
    Set gbl_frmAkces = Me
    Set gbl_frmPodrobnosti = gbl_frmAkces.sfPodrobnosti.Form
    Seems to be working, mostly, except that I just ran into another oddity Not sure if it's the same issue, although the symptoms are the same.

    In the subform, I have this, which again bombs.
    Code:
    If Recordset.RecordCount = 0 Then Stop
    Changing it to this does not help:
    Code:
    If gbl_frmPodrobnosti.Recordset.RecordCount = 0 Then Stop
    I had to again change it to use the clone


    Code:
    If RecordsetClone.RecordCount = 0 Then Stop
    or
    Code:
    If gbl_frmPodrobnosti.RecordsetClone.RecordCount = 0 Then Stop
    And if that wasn't enough, neither of these works.
    Code:
    If Forms("Podrobnosti").Recordset.RecordCount = 0 Then Stop
    If Forms("Podrobnosti").RecordsetClone.RecordCount = 0 Then Stop

  2. #17
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    What happens if you ignore the globals and simply try

    Code:
    If Me.sfPodrobnosti.Form.Recordset.Recordcount = 0 Then Stop
    I'm not convinced by the need for them, and they might be obfuscating the issue?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #18
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by Minty View Post
    What happens if you ignore the globals and simply try

    Code:
    If Me.sfPodrobnosti.Form.Recordset.Recordcount = 0 Then Stop
    I'm not convinced by the need for them, and they might be obfuscating the issue?
    This is in the subform, not the main form, so should it not be this?
    Code:
    If Me.Recordset.Recordcount = 0 Then Stop
    And since Me is the default object, why would it be necessary at all? But I'll try it - anything to make some sense of this.

  4. #19
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    Quote Originally Posted by pdanes View Post
    This is in the subform, not the main form, so should it not be this?
    Code:
    If Me.Recordset.Recordcount = 0 Then Stop
    Apologies, the way you are setting the variables implies (my reading of it) referring to the sub form from the parent, hence I made the assumption.
    And since Me is the default object, why would it be necessary at all? But I'll try it - anything to make some sense of this.
    I always qualify the Me reference, as it guarantees I'm identifying the current form object. Just old fashioned me
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #20
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by Minty View Post
    Apologies, the way you are setting the variables implies (my reading of it) referring to the sub form from the parent, hence I made the assumption.
    Nothing to apologise for - I'm grateful for the suggestions. I set all the references in the main form's Load event, so that I am sure the subform has also finished loading, but I use the references all over the place. This specific case was in the subform, so I tried to not use any references, just use the default, which I assumed referred to the subform's bound recordset. And it seems to, usually. But not here, again to my complete mystification.

    I always qualify the Me reference, as it guarantees I'm identifying the current form object. Just old fashioned me
    I'm not a very good typist, and I like 'cleaner' syntax, so I tend to use defaults where I can. But it does bite me in the fundament sometimes. I'll try specifying Me, see if it helps.

  6. #21
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    Glad you are getting somewhere with it.

    I never ever type
    Code:
    .Value
    at the end of setting a control value.
    There is something somewhere (in the depths of Access VBA) than breaks when you add it, but I can't remember what it is.

    I'm currently writing a load of Excel automation (in Excel rather than Access) and you have to type .Value in a lot of instances, and it drives me mad...
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  7. #22
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    The Me.Recordset syntax didn't work either. Only using RecordsetClone works, and that always works.

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

Similar Threads

  1. Nothing Works for Recordset in VBA
    By vetabz in forum Queries
    Replies: 3
    Last Post: 01-27-2017, 02:21 PM
  2. Replies: 9
    Last Post: 06-28-2016, 10:12 AM
  3. A2003 - Me.RecordsetClone.MoveLast not working
    By GraeagleBill in forum Programming
    Replies: 3
    Last Post: 05-25-2016, 08:52 PM
  4. Recordsetclone NOT picking up records from linked table
    By CementCarver in forum Programming
    Replies: 1
    Last Post: 10-15-2013, 10:01 AM
  5. Compact and Repair Database "Bombs"
    By GraeagleBill in forum Access
    Replies: 16
    Last Post: 09-27-2011, 09:23 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