You will exit the editor and just launch the form as you normally do.
You will exit the editor and just launch the form as you normally do.
great! thanks.. it show x = 4 (the agencyid) which is correct. checking the other lines
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
So you're not running the code I posted for a select query?
I ran that as well first, and the values were all correct.
Did the SELECT query return any records?
I inserted a record into the table to test it, and it sees the values of 4 for x and the incidentid as well
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'"
My bad here. You need to change the code to:
CurrentDb.Execute "INSERT INTO tblAgencyIncident(InternalIncidentID, AgencyID) Values (" & Me.InternalIncidentID & ", " & x & ");", dbFailOnError
YES. After the x= line executes the value of x should be 4.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'"
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
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.
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
The msgbox pops up and changes according to the selected value 4 or 5. It displays the correct value.
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?