Page 5 of 7 FirstFirst 1234567 LastLast
Results 61 to 75 of 104
  1. #61
    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 will exit the editor and just launch the form as you normally do.

  2. #62
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    great! thanks.. it show x = 4 (the agencyid) which is correct. checking the other lines

  3. #63
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    For the code below, it shows x with the correct values, as well as Me.InternalIncidentID yet nothing populates in the table.
    Code:
     x = [Forms]![frmNewMain]![Combo573]
       If x = True Then
          CurrentDb.Execute "INSERT INTO tblAgencyIncident(InternalIncidentID, AgencyID) Values (" & Me.InternalIncidentID & ", 'x');", dbFailOnError

  4. #64
    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 you're not running the code I posted for a select query?

  5. #65
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    I ran that as well first, and the values were all correct.

  6. #66
    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 SELECT query return any records?

  7. #67
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    I inserted a record into the table to test it, and it sees the values of 4 for x and the incidentid as well

  8. #68
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    When I hover over the first line of code, it shows x as 0 and the combo573 as 4. This line below " if x ...." it shows x = 0. At that point of the code, should x be = 4?
    Code:
      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'"

  9. #69
    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
    My bad here. You need to change the code to:
    CurrentDb.Execute "INSERT INTO tblAgencyIncident(InternalIncidentID, AgencyID) Values (" & Me.InternalIncidentID & ", " & x & ");", dbFailOnError

  10. #70
    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
    When I hover over the first line of code, it shows x as 0 and the combo573 as 4. This line below " if x ...." it shows x = 0. At that point of the code, should x be = 4?
    Code:
      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'"
    YES. After the x= line executes the value of x should be 4.

  11. #71
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    I made the change you suggested, and it picks up x as = 0 both at the beginning of the If x statement and in the Values section. This is in spite of the fact that it shows [Forms]![frmNewMain]![Combo573] as = 5.
    Code:
    Dim x As Integer
       x = [Forms]![frmNewMain]![Combo573]
       If x = True Then
          CurrentDb.Execute "INSERT INTO tblAgencyIncident(InternalIncidentID, AgencyID) Values (" & Me.InternalIncidentID & ", " & x & ");", dbFailOnError

  12. #72
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    Oops my bad, it wasn't showing the other values because I needed to step through those lines for the value to change. When I did step through the other lines it showed x as having the correct value, as well as the incidentid. So it sees that values but won't insert.

  13. #73
    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 make some changes:
    Code:
    Dim x As Integer
       x = [Forms]![frmNewMain]![Combo573]
       MsgBox "The value of x is [" & x & "]"
       If x = True Then
          CurrentDb.Execute "INSERT INTO tblAgencyIncident(InternalIncidentID, AgencyID) Values (" & Me.InternalIncidentID & ", " & x & ");", dbFailOnError

  14. #74
    tbbrown32 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    79
    The msgbox pops up and changes according to the selected value 4 or 5. It displays the correct value.

  15. #75
    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
    Oops my bad, it wasn't showing the other values because I needed to step through those lines for the value to change. When I did step through the other lines it showed x as having the correct value, as well as the incidentid. So it sees that values but won't insert.
    I didn't see this post before my question. Thank you. It looks like it is working as expected. This is supposed to add a new record to the tblAgencyIncident, right?

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