arunakumari02
Registered User.
- Local time
- Today, 15:32
- Joined
- Jun 2, 2008
- Messages
- 91
When I try update the table and call "open form" again the last record is getting duplicated.
Code is:
If Forms!frmPipeline("chkResourceOptimizer" & intRow) = False And _
Not IsNull(Forms!frmPipeline("txtProjectID" & intRow)) Then
DoCmd.RunSQL "UPDATE tblProjects SET ResourceOptimizer=False WHERE ProjectID = " & Forms!frmPipeline!("txtProjectID" & intRow)
Call Form_Open(1)
Me.Refresh
End If
Form_Open:
strSQL = "SELECT DISTINCT ProjectID, Title, SEOwner From tblProjects WHERE ResourceOptimizer=True ORDER BY ProjectID DESC"
Set rstProjects = CurrentDb.OpenRecordset(strSQL)
'Debug.Print rstProjects!ProjectID & " " & rstProjects!Title
'Debug.Print rstProjects.RecordCount
If rstProjects.RecordCount > 0 Then
rstProjects.MoveLast
For intRow = 1 To rstProjects.RecordCount
Forms!frmPipeline!("chkResourceOptimizer" & intRow) = True
Forms!frmPipeline!("txtProjectID" & intRow) = rstProjects!ProjectID
Forms!frmPipeline!("txtTitle" & intRow) = rstProjects!Title
Forms!frmPipeline!("txtSEOwner" & intRow) = rstProjects!SEOwner
Debug.Print rstProjects!ProjectID & " " & rstProjects!Title
rstProjects.MovePrevious
Next
Else
MsgBox "No records are selected"
End If
rstProjects.Close
When I run the form the output:
This ouput when I open form:
checkbox ID title Owner
* 1 xx john
* 2 yy mary
* 3 zz king
When uncheck (which is not shown here) the checkbox next to the id the row should be deleted. The row is getting deleted but duplicate record of the last row is showing up
The output now looks like:
checkbox ID title Owner
* 2 yy mary
* 3 zz king
* 3 zz king
Any help is appreciated
Code is:
If Forms!frmPipeline("chkResourceOptimizer" & intRow) = False And _
Not IsNull(Forms!frmPipeline("txtProjectID" & intRow)) Then
DoCmd.RunSQL "UPDATE tblProjects SET ResourceOptimizer=False WHERE ProjectID = " & Forms!frmPipeline!("txtProjectID" & intRow)
Call Form_Open(1)
Me.Refresh
End If
Form_Open:
strSQL = "SELECT DISTINCT ProjectID, Title, SEOwner From tblProjects WHERE ResourceOptimizer=True ORDER BY ProjectID DESC"
Set rstProjects = CurrentDb.OpenRecordset(strSQL)
'Debug.Print rstProjects!ProjectID & " " & rstProjects!Title
'Debug.Print rstProjects.RecordCount
If rstProjects.RecordCount > 0 Then
rstProjects.MoveLast
For intRow = 1 To rstProjects.RecordCount
Forms!frmPipeline!("chkResourceOptimizer" & intRow) = True
Forms!frmPipeline!("txtProjectID" & intRow) = rstProjects!ProjectID
Forms!frmPipeline!("txtTitle" & intRow) = rstProjects!Title
Forms!frmPipeline!("txtSEOwner" & intRow) = rstProjects!SEOwner
Debug.Print rstProjects!ProjectID & " " & rstProjects!Title
rstProjects.MovePrevious
Next
Else
MsgBox "No records are selected"
End If
rstProjects.Close
When I run the form the output:
This ouput when I open form:
checkbox ID title Owner
* 1 xx john
* 2 yy mary
* 3 zz king
When uncheck (which is not shown here) the checkbox next to the id the row should be deleted. The row is getting deleted but duplicate record of the last row is showing up
The output now looks like:
checkbox ID title Owner
* 2 yy mary
* 3 zz king
* 3 zz king
Any help is appreciated