Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    What is this code?

    In the attached file when you go to the frmAttendance, it gives you choice of selecting meetings by their dates.

    It seems that an error occurs when you choose a meeting date and you choose personnell who attended it. The system crashes, it opens up a window of
    source code which I take it is where the program operates on the names. However, in my case it crashes at thus point.

    Now I am unaware until now what that code was for. I assume it is associated with frmAttendance. I also assume it works, but in my particular case it does not.

    I am unsure what the error is, but first things first - what is this code? How do I get to it without causing a crash? It looks like some rewritten library code, but I cannot be sure.



    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed
    Attached Files Attached Files

  2. #2
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, I need some help on this post. When I open frmAttendance in the attached db, I select a meeting by its date and then I select who was there. Say it is categorized as all. Then when I select a name, the system crashes with a runtime error #2471.

    I am not sure what has changed. It sure does not like my putting the name in the subform shown on frmAttendance. I need to know what is causing this? The attached file in the previous post contains the db in question.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Well, the short answer is the table "tblAttendance" has a field named "ysnMeetingID" and the code is looking for a field name of "MeetingID".

    There is a text box on "frmAttendance" that has the control source of
    Code:
    =meetingAttendance([cboMeetingID],[optPersonnel])
    In the function meetingAttendance, there is a line
    Code:
            totalPersonnel = DCount("[MeetingID]", "qryAttendance", "[MeetingID] = " & MeetingID)
    The field name should be
    Code:
            totalPersonnel = DCount("[ysnMeetingID]", "qryAttendance", "[ysnMeetingID] = " & MeetingID)
    Note: in the function, there are 4 lines with the wrong field name!!

  4. #4
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I thought it was something like that, what with the constant changing of my VBA code and db design. However, I need to ask how you found it. I tried yesterday to do so and I could not.

    What procedure did you use? Please understand that this is not code that I wrote. It is code written by someone else that I tried to integrate
    into my db.

    I just need to know the debugging methods that you used to find the answer you gave me. I could
    walk through the code using the debugger, but that was about it.

    Any help appreciated. Thanks in advance.

    Respectfully,


    Lou Reed

  5. #5
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    I'm no expert on VBA but ill give it a shot. This shows it cant find meetingID.

    Click image for larger version. 

Name:	meeting ID.png 
Views:	26 
Size:	8.7 KB 
ID:	28661



    This highlights the line which is causing the error. Looks like its counting how many times that meetingID appears.

    Click image for larger version. 

Name:	Debug.png 
Views:	26 
Size:	19.2 KB 
ID:	28662

  6. #6
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, but is it counting MeetingID or ysnMeetingID? I do not see how it is searching for ysnMeetingID and finding MeetingID.

    Specifically, where is the search term ysnMeetingID used? I see the code and the table of relationships (with ysnMeetingID used in tblAttendance), but I cannot see exactly where
    MeetingID is used and ysnMeetingID should be used. The VBA code is looking for MeetingID as I can tell from the VBA source. But at this point what difference does that make?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  7. #7
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    MeetingID doesn't exist. This is why the error exists instead. Its looking to count something and cant even find where to look.

  8. #8
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I understand that. But where does it connect the table relationships with the code? How was function meetingAttendeance connected to frmAttendance? That is what I do not see.

    It seems you can call that MeetingID or ysnMeetingID. What is the difference? The function meetingAttendance is only looking for a number in that place. It should not care what it is called. MeetingID and ysnMeetingID should be okay.

    Why is function meetingAttendance looking for ysnMeetingID, why should it care? It is only looking for a number which represents the MeetingID.

    Only a number. I am speaking as a programmer not as a VBA programmer. I forgot the method of the connecting the graph with the VBA code.

    That is what is confusing me. Not the logic or the table of relationships. It is the connection.

    For instance if I replaced meetingID with the word strawberries, it should not make any difference, the compiler
    will change it to something hexadecimal anyway. We only give it a user name that is friendly for our convenience.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  9. #9
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Well the code is being told to count a field (basically). You must define that field. So if its not named exactly the same it cant count it.

    As for where this code is triggered. I don't know. I'm looking and if I see it ill tell you. But. on the open event of the form you have a macro that runs two macros. Have you been watching too much pimp my ride? haha.

    you can run both query's from the on open event macro on the form. there's no need to create an actual macro on the left to run. Not a big issue tho. Ill keep looking.
    Last edited by Homegrownandy; 05-16-2017 at 08:39 AM. Reason: changed on load to on open.

  10. #10
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    the form heading macro doesn't work for me either.

  11. #11
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Please understand that this is code that I am just using, I did not write it. Being something of a newbie on this stuff (but not a newbie on programming). If you look at the headers in the software source code it appears to be some generalized software code.

    Hence on most of the functions the name of the input variable does not matter. It is only a placeholder.

    Take a trig function. I want the sin of 30 degrees. I change 30 degrees to radians and pass it to the sin function sub. Who cares what I call the variable holding the radians value? As i said let us call it strawberries. Then strawberries holds the value of 30 degrees in radians. It is passed to the trig function sin which has variable for radians that is called cream. In the end this should not matter because it will all be translated to machine code.

    So why is the graphical part looking for ysnMeetingID? It should be somehow generated by MS Access 2010. That is my guess.

    I see what you say is that I am not being consistent. OK. Where does consistency fail here?

    I believe that I was consistent. The function meetingAttendance must
    be much more closely tied in to the graphical part of the db than I first thought. Hence they must share variable names and failure to be consistent over both areas (graph and code).

    That is my guess. It can be confirmed by explaining the code tie-in with the combo box.

    That was my first post in this thread. What is this code?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  12. #12
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, let me ask a simple question: what calls Function meetingAttendance? That would help a lot if I knew that.

    Respectfully,

    Lou Reed

  13. #13
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, now this is confusing. If you download the db that I put in post #1, you will see that in frmAttendance, that the control source is well ... nothing. If you make it ysnMeetingID in the VBA code and change the control source from nothing to ysnMeetingID, then it will work and has a control source. But how did it work initially without a control source for cboMeetingID?

    That is one for Ripley. This works (it seems) without a control source. Again, this is the purpose of the thread. What calls function attendanceMeetingID?

    Respectfully,

    Lou Reed

  14. #14
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I made a mistake here in the last post. The row source has SQL code that breaks down into MeetingID and MeetingDate when run. But control source is still nothing.

    Also as I asked before: what calls Function meetingAttendance? It would make things a lot easier if I knew.

    Respectfully,

    Lou Reed

  15. #15
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, I think That I see the problem here. I have only built combo boxes using the combo box wizard. I have never created them without the wizard. That is why there were many questions about tblAttendance.

    I just was not familiar with the combo box creation procedure w/o the wizard and how one can access the info once the combo box is created. That was the source of most of my questions.

    Sorry about the palaver. I still might have more questions.

    Respectfully,

    Lou Reed

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

Similar Threads

  1. Replies: 12
    Last Post: 08-23-2016, 09:22 AM
  2. Replies: 20
    Last Post: 10-13-2015, 09:05 AM
  3. Replies: 3
    Last Post: 10-16-2014, 08:49 AM
  4. Replies: 7
    Last Post: 05-28-2013, 09:11 AM
  5. Replies: 1
    Last Post: 05-04-2013, 12:19 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