Page 2 of 7 FirstFirst 1234567 LastLast
Results 16 to 30 of 104
  1. #16
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922

    Let's take them one at a time. On the ProgramTest tab the cbo's that won't write. To where did you want them to write? As best I can tell, there is no Agency Name field in the tblIncidents table which is the RecordSource of the Form.

  2. #17
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    As far as the three cbo's on three separate SubForms cascading, Their RowSource should be based on a static query that references the limiting cbo.

  3. #18
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Did I loose you? Are you still there?

  4. #19
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    Oops my apologies, I didn't get any notifications via email that there were any replies on the thread, so I assumed there was nothing new.

  5. #20
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    The programtest tab cbo's were supposed to write to the associative tables. For each level of the organization (agency, department, program) there is an associative table tied back to the Incidents table. There is one for each level because an incident can apply at any (or only one or two) of the three levels. Then agency name field, for example, is connected to the Incidents table via the AgencyIncidents table. The working tab (that doesn't sort subsequent cbo's) writes to each associative table when a value is selected. Hopefully that provides a little more background!

  6. #21
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    Quote Originally Posted by RuralGuy View Post
    As far as the three cbo's on three separate SubForms cascading, Their RowSource should be based on a static query that references the limiting cbo.
    This makes sense, except then when I scroll through different incidents on the main form, the cbo's don't update. Right now they do because they are tied to the incidentID. They've already got the queries in place and cascade just fine, but they don't write to the tables.

  7. #22
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I've got some stuff to do this morning. I'll try and get back to you this afternoon.

  8. #23
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by tbbrown32 View Post
    This makes sense, except then when I scroll through different incidents on the main form, the cbo's don't update. Right now they do because they are tied to the incidentID. They've already got the queries in place and cascade just fine, but they don't write to the tables.
    They will not scroll unless you requery the SubForms, but you may have other issues.

  9. #24
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by tbbrown32 View Post
    The programtest tab cbo's were supposed to write to the associative tables. For each level of the organization (agency, department, program) there is an associative table tied back to the Incidents table. There is one for each level because an incident can apply at any (or only one or two) of the three levels. Then agency name field, for example, is connected to the Incidents table via the AgencyIncidents table. The working tab (that doesn't sort subsequent cbo's) writes to each associative table when a value is selected. Hopefully that provides a little more background!
    The only tables/queries you can write to without an Update Query is the RecordSource of the Form.

  10. #25
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    Okay, it sounds like I'll either need to do an update query or requery the Subforms. Thanks!

  11. #26
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79

    Attempt

    Below is my attempt to Insert the cbo value into the composite table. It currently errors out. Again, I am relatively new to VBA, so I'm sure this has some holes in it! I would gladly welcome any advice. Thanks

    Private Sub Combo573_AfterUpdate()
    Dim x As String
    x = [Forms]![frmNewMain]![Combo573]

    If x = True Then
    CurrentDb.Execute "INSERT INTO tblAgencyIncident(InternalIncidentID, AgencyID) Values ("Me.InternalIncidentID", "x")"
    Else
    CurrentDb.Execute "DELETE FROM AgencyIncident (InternalIncidentID, AgencyID)"
    WHERE InternalIncidentID = "Me.InternalIncidentID" And AgencyID = "x"
    End If

    End Sub

    -The error seems to be (for now) centered around the Me.InternalIncidentID value. I'm also getting an ambiguous name detected error for Combo573 since I am using it elsewhere in other code.

  12. #27
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I'll see if I can fix it.

  13. #28
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    See if this works:
    Code:
    Private Sub Combo573_AfterUpdate()
       Dim x As String
       x = [Forms]![frmNewMain]![Combo573]
    
       If x = True Then
          CurrentDb.Execute "INSERT INTO tblAgencyIncident(InternalIncidentID, AgencyID) Values (" & Me.InternalIncidentID & ", 'x');"
       Else
          CurrentDb.Execute "DELETE FROM AgencyIncident (InternalIncidentID, AgencyID)" & _
                            " WHERE InternalIncidentID = " & Me.InternalIncidentID & " And AgencyID = 'x';"
       End If
    
    End Sub
    Notice how using the # (code tags) helps the readability?

  14. #29
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    It's closer to working, but I'm getting the 'Too few parameters. Expected 1." error. It's highlighting this line of code:
    Code:
    CurrentDb.Execute "INSERT INTO tblAgencyIncident(InternalIncidentID, AgencyID) Values (" & Me.InternalIncidentID & ", 'x');"

  15. #30
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    And actually, I'm displaying a text value in the cbo, but the inserted value is an integer, so I've now changed to Dim x as Integer. Is it possible that the fact that I'm displaying the text value but inserting the numeric value (pk) into the table is what is causing the issue?

    edit: I also changed the delete from table reference to tblAgencyIncident because I had it in as AgencyIncident. However, it still errors out.

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

Similar Threads

  1. Replies: 11
    Last Post: 09-03-2015, 11:12 AM
  2. Replies: 4
    Last Post: 06-18-2014, 08:31 PM
  3. Combo box to filter a combo box
    By svrich in forum Access
    Replies: 20
    Last Post: 04-13-2014, 10:36 PM
  4. Replies: 1
    Last Post: 10-01-2013, 09:25 PM
  5. Combo Box filter – help!
    By catat in forum Forms
    Replies: 1
    Last Post: 08-24-2010, 04:15 PM

Tags for this Thread

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