Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 40
  1. #16
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    However, now Qery3 is messed up. It uses Query2 says something like file renamed or renumbered. They have been.

    Do I just redo query3 and use Query2 as a Source. it would seem the easiest way?



    Respectfully,

    Lou Reed

  2. #17
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    Some records in tblPersonnel do not have Organization value, most of them have 1 as the value. Enter more varied Organization values and you will see the list change in the subform when each radio button is pressed.

    Again, the records displayed on this subform are dictated by records in tblAttendance.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #18
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Code:
    "INSERT INTO tblAttendance(ysnMeetingID, PersonnelID) SELECT " & Me.cboMeetingID & " AS MID, PersonnelID FROM tblPersonnel"
    This is the SQL code you said to use if I wanted all branch members to be associated with each meeting data. that is fine, but where to put it?

    I obviously have repaired the query, but where does this go?

    The original and working query is:

    Code:
    SELECT tblAttendance.Status, tblAttendance.Notes, tblPersonnel.isDeleted, [LastName]+",  "+[FirstName] AS Name, tblPersonnel.Organization, tblPersonnel.LastName, tblPersonnel.FirstName, tblAttendance.ysnMeetingID
    FROM tblPersonnel INNER JOIN tblAttendance ON tblPersonnel.PersonnelID = tblAttendance.PersonnelID
    WHERE (((tblPersonnel.isDeleted)=False) AND ((tblPersonnel.Organization) Like IIf([Forms]![frmAttendance]![optPersonnel]=0,"*",[Forms]![frmAttendance]![optPersonnel])) AND ((tblAttendance.ysnMeetingID)=[Forms]![frmAttendance]![cboMeetingID]))
    ORDER BY tblPersonnel.LastName, tblPersonnel.FirstName;
    So where does your line go?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  4. #19
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    That line would go in some event, perhaps a button Click or combobox AfterUpdate. That is for you to determine based on your preferences and business process.

    CurrentDb.Execute "INSERT INTO tblAttendance(ysnMeetingID, PersonnelID) SELECT " & Me.cboMeetingID & " AS MID, PersonnelID FROM tblPersonnel"

    That code will create records in tblAttendance to associate EVERY person from tblPersonnel to the meeting selected in cboMeetingID. And if you want to make sure there are no duplicate entries (maybe user accidentally clicks button twice), suggest setting tblAttendance with compound index to prevent duplicate ysnMeetingID and PersonnelID pairs.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #20
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Code:
    SELECT tblAttendance.Status, tblAttendance.Notes, tblPersonnel.isDeleted, [LastName]+",  "+[FirstName] AS Name, tblPersonnel.Organization, tblPersonnel.LastName, tblPersonnel.FirstName, tblAttendance.ysnMeetingID
    FROM tblPersonnel INNER JOIN tblAttendance ON tblPersonnel.PersonnelID = tblAttendance.PersonnelID
    WHERE (((tblPersonnel.isDeleted)=False) AND ((tblPersonnel.Organization) Like IIf([Forms]![frmAttendance]![optPersonnel]=0,"*",[Forms]![frmAttendance]![optPersonnel])) AND ((tblAttendance.ysnMeetingID)=[Forms]![frmAttendance]![cboMeetingID]))
    ORDER BY tblPersonnel.LastName, tblPersonnel.FirstName;
    Now where does this query go. I would imagine that it stays right where it is.

    The INSERT query as you aid goes into the afterupdate.

    Is this true?

    I at first thought it was just another line in the original query we discussed, query2; which would make it a compound query.

    You said this is separate from query2. Correct?

    Please elaborate.

    Respectfully,


    Lou Reed
    Last edited by Lou_Reed; 05-25-2017 at 08:42 AM. Reason: correction

  6. #21
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Code:
    And if you want to make sure there are no duplicate entries (maybe user accidentally clicks button twice), suggest setting tblAttendance with compound index to prevent duplicate ysnMeetingID and PersonnelID pairs.


    Please explain this statement. I clearly do not want duplicates in my db.

    I already have a check for duplicates query in my db.I inherited it along with this project.

    Any help appreciated. Thanks in advance.

    Respectfully,


    Lou Reed

  7. #22
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I am curious abut the statement that you gave me above. I have put in the after update event for the cboMeetingID. it is of course SQL code, but I have seen SQL code
    in after locations before. I think that is alright.

    However, the attachment before it is another thing entirely. The CurrentDb.Execute prefix I assume goes before the SQL in the after update location. Is this correct?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  8. #23
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I tried what you said and the result was a error message that MS Access cannot find...

    The db is in the zip file and the screenshot is in the other file. What do I need to change to make this
    right?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed
    Attached Thumbnails Attached Thumbnails Capture.PNG  
    Attached Files Attached Files

  9. #24
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    Remove that SQL statement from the OnChange event property. Should be [Event Procedure] then put code from post 19 into the VBA. As well as Me.sfrmAttendance.Requery.

    Code looks like:
    Code:
    Private Sub cboMeetingID_Change()
    CurrentDb.Execute "INSERT INTO tblAttendance(ysnMeetingID, PersonnelID) SELECT " & Me.cboMeetingID & " AS MID, PersonnelID FROM tblPersonnel"
    Me.sfrmAttendance.Requery
    End Sub
    Right now, if user later selects a meeting previously selected, then another set of personnel records for that meeting will be saved to tblAttendance. To prevent this suggest you set compound index in the table. Delete records from tblAttendance and then set the index as shown in image.Click image for larger version. 

Name:	Capture.PNG 
Views:	14 
Size:	17.6 KB 
ID:	28874
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #25
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I used your syntax in the last line of the onchange Sub, but still got an error when I tried to update after selecting the meeting date.
    It is error 3061.

    What is wrong here?

    Respectfully,

    Lou Reed
    Attached Files Attached Files

  11. #26
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,895
    You did not exactly follow the code example. Must concatenate the combobox.

    strQuery = "INSERT INTO tblAttendance(ysnMeetingID, PersonnelID) SELECT " & Me.cboMeetingID & " AS MID, PersonnelID FROM tblPersonnel"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #27
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, what did I do wrong? I thought that strQuery must be on one line and must not have double quote (actually no quotes single or double) and no &.

    It seems that I am wrong.

    The strQuery must be devoid of double quotes?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  13. #28
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, I made the correction. The tblAttendance took everyone except Boris Karloff. Why was he left off?

    Also, I thought that strQuery had to be one line and no double quotes? Is this ture.

    Respectfully,

    Lou Reed

  14. #29
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    It seems in tblAttendance that Boris Karloff is in there, his PersonnelID is 3. But he does not show up in sfrmAttendance. That is confusing to me.

    Also, do we use a composite or a compound key? I am not sure of the difference.

    Since, I have run the query twice now for the same MeetingDate, I guess that I must delete all the rows or something will happen when i put in the composite key in tblAttendance?

    There are many duplicates in tblAttendance right now.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  15. #30
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I really need an answer as to why Boris Karloff was let out in sfrmAttendance. He is in tblAttendance.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

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

Similar Threads

  1. Query entire table at once
    By Little in forum Queries
    Replies: 9
    Last Post: 09-01-2016, 05:20 PM
  2. Update and Append Entire table in Access
    By Yoyo120 in forum Access
    Replies: 1
    Last Post: 06-05-2014, 02:42 PM
  3. Insert entire row from query into new row in another table
    By chris.williams in forum Programming
    Replies: 3
    Last Post: 10-13-2011, 01:38 PM
  4. Replies: 1
    Last Post: 07-21-2010, 07:27 AM
  5. How to loop code to run through entire table
    By kmajors in forum Reports
    Replies: 9
    Last Post: 04-23-2010, 09:27 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