Page 4 of 7 FirstFirst 1234567 LastLast
Results 46 to 60 of 104
  1. #46
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    Using Debug.Print shows that the value of x (AgencyID) is correct but that Me.InternalIncidentID has no value i.e. it doesn't print anything for it.

  2. #47
    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
    Code:
    Dim x As Integer
    x = [Forms]![frmNewMain]![Combo573]
    If x = True Then
    You have defined x as an Integer but you are comparing it to True which is any non zero value. Is that what you want?

  3. #48
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    Yes, that should be fine. I want it to write to the table when something is filled in, so True should work for my needs.

  4. #49
    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
    Have you single stepped your code. Does it execute the Update query? Have you tried to create a new query that is just a SELECT query with the same criteria and see if any record qualifies?

  5. #50
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    New queries work, but I'm not sure how I would SELECT for the Me.InternalIncidentID value. It's not seeing the value for some reason, maybe the way my form is constructed. From what I can tell, it isn't executing because it needs the InternalIncidentID in order to write to the composite PK, and it's not getting it for some reason so it doesn't write.

  6. #51
    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
    Try this code:
    Code:
    Private Sub Combo573_AfterUpdate()
       On Error GoTo Combo573Error
    
       Dim x As Integer
       x = [Forms]![frmNewMain]![Combo573]
       If x = True Then
          '      CurrentDb.Execute "INSERT INTO tblAgencyIncident(InternalIncidentID, AgencyID) Values (" & Me.InternalIncidentID & ", 'x');", dbFailOnError
          MsgBox "Going to excute the SELECT query!"
          CurrentDb.Execute "Select * From tblAgencyIncident " & _
                            "WHERE InternalIncidentID = " & Me.InternalIncidentID & " and AgencyID = 'x'"
       Else
          CurrentDb.Execute "DELETE FROM tblAgencyIncident WHERE InternalIncidentID = '" & Me.InternalIncidentID & "' AND  AgencyID = 'x'", dbFailOnError
       End If
    ExitCombo573:
       Exit Sub
    
    Combo573Error:
       MsgBox Err & ": " & vbCrLf & Err.Description
       Resume ExitCombo573
    
    End Sub

  7. #52
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    No error showing with the new code, still no write. This seems odd that I wouldn't get any error or message box.

  8. #53
    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 the MsgBox pop up?

  9. #54
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    No, no message box came up

  10. #55
    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
    So it never even tried to execute the Select query. Do you know how to single step the code? I think that is next.

  11. #56
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    No unfortunately I don't know how to do that

  12. #57
    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
    When you are looking at the posted code, put your cursor to the left of the margin and click. It will put a dot there which is a breakpoint and the code will stop executing at that line. I would put the breakpoint at the " x = [Forms]![frmNewMain]![Combo573]" line. you can then use the F8 key to single step the code. If you hover over a variable the debugger will display it's value and the highlighting will show you the line of code that is executing.

  13. #58
    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
    Any luck? It should be pretty easy.

  14. #59
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    It lets me put the breakpoint in but when I hit F8 or select step into it makes a noise and doesn't work. I've looked it up and made sure that the "Use Access special keys" option is selected (it hasn't worked either selected or unselected) but to no avail. This is strange

  15. #60
    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
    You need to run the program after putting in the breakpoint. when the code hits the breakpoint it will stop and put you back looking at the code.

Page 4 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