Results 1 to 4 of 4
  1. #1
    SPerricone is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Vermont
    Posts
    3

    2003 to 2010 forms reference in code seems broken

    I have an old Access database that's been upgraded to 2010 (it was originally written, not by me, back in the mid-late 1990s). The original developer used a lot of unbound controls in his forms that he populated from combos. This problem will probably come back in other parts of this database but right now I need to fix this part and I can't find a good answer for how to go about it. Anyway, the problem:

    The unbound control "Posted Items" gets populated by a combo box. When the user wants to edit one of the posted items, she clicks on the one she wants to edit and it's supposed to feed the necessary parameters to the edit form so it opens up the correct posted item. It is failing at this because it's not successfully obtaining the parameters from the form to send to this bit of code:


    Code:
    Private Sub Posted_items_Click()
       Dim stDocName As String
        Dim stLinkCriteria As String
        Dim cnt As Integer
        Dim postnum, linenum
        
    For cnt = 0 To [Posted items].ListCount
         If Form![Posted items].Value = Form![Posted items].Column(0, cnt) Then
             postnum = Form![Posted items].Column(1, cnt)
             linenum = Form![Posted items].Column(0, cnt)
         End If
        Next
        stDocName = "cshlin edit"
        ' Forms![Edit Posts]![Posted items]
        stLinkCriteria = "[num]='" & postnum & "' AND [ln#]=" & linenum
        DoCmd.OpenForm stDocName, acNormal, , stLinkCriteria, acFormEdit
    End Sub
    If there's a reference I need to put in, please tell me exactly what it's named. There are not MISSING references in the library at this point. I'm guessing that something's changed in how forms get references and that's why those fields are blank now. I have people unable to work and collections going uncollected while I'm trying to fix this in emergency mode. I appreciate any time you can give me to try and figure this out.

  2. #2
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254
    Sperricone – Without taking a look at the db, this is just speculation. Therefore, before making any change, make a copy of the db and do the testing on the copy. That being said, I might try…

    Private Sub Posted_items_Click()
    Dim stDocName As String
    Dim stLinkCriteria As String
    Dim cnt As Integer
    Dim postnum, linenum

    'cnt integer to step through list as well as refer to row to set variable when condition is true ???

    For cnt = 0 To Me![Posted items].ListCount 'May need -1 after ListCount
    If Me![Posted items].Value = Me![Posted items].Column(0, cnt) Then
    postnum = Me![Posted items].Column(1, cnt)
    linenum = Me![Posted items].Column(0, cnt)
    End If
    Next
    stDocName = "cshlin edit"
    stLinkCriteria = "[num]='" & postnum & "' AND [ln#]=" & linenum
    DoCmd.OpenForm stDocName, acNormal, , stLinkCriteria, acFormEdit

    and see if it produces the desired results.

    Hope this helps,

    Jim

  3. #3
    SPerricone is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Vermont
    Posts
    3
    Ok, so I tried that and I'm still having problems. I also tried the -1 and that didn't help either. I'm still confused by the for...next and I'm not sure why I can't just reference the fields in the listbox (finally found in 2010 where it tells me what sort of object we're dealing with) using the .selected thingie but I guess it can't tell where in the list it is without the for...next? Is there some way to tell it "this line in the list box, grab these two fields from it"? that isn't like the above?

  4. #4
    SPerricone is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Vermont
    Posts
    3
    MUHAHAHAHAHHA I GOT IT!!!!
    Code:
    For cnt = 0 To [posted items].ListCount - 1
         If Me![posted items].ListIndex = cnt Then
             postnum = Me![posted items].Column(1, cnt)
             linenum = Me![posted items].Column(0, cnt)
         End If
        Next
    This works. Thanks for pointing me in better directions than I'd been going in!

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

Similar Threads

  1. Broken reference
    By NOTLguy in forum Programming
    Replies: 5
    Last Post: 11-10-2012, 08:26 AM
  2. Creating a broken reference
    By dandoescode in forum Programming
    Replies: 3
    Last Post: 07-03-2012, 07:44 PM
  3. error message about broken reference
    By keighley in forum Access
    Replies: 1
    Last Post: 05-10-2012, 06:42 PM
  4. Broken reference
    By cassidym in forum Reports
    Replies: 15
    Last Post: 09-18-2011, 07:57 AM
  5. Replies: 1
    Last Post: 06-23-2011, 07:19 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