J
John Phelan
I have a list box in which information gets listed from a field (of course).
However, every time I add a new record successfully, a blank line gets added
to the list box. How can I prevent that from happening?
Below is the code I am using behind the form and behind the listbox on the
form:
Form Code (also, see listbox code below)
Option Compare Database
Option Explicit
Private Sub cmdAssignCal_Click()
txtAssignDate = CalendarDlg(txtAssignDate)
ExitLine:
Exit Sub
End Sub
Private Sub cmdDueCal_Click()
txtDueDate = CalendarDlg(txtDueDate)
ExitLine:
Exit Sub
End Sub
Private Sub Form_Current()
Me!TaskIDf =
Forms![team_top_sub_task]![Team_Sub_Tasks]![Team_Sub_tasks_actions].Form!TaskID
Me!Tasks =
Forms![team_top_sub_task]![Team_Sub_Tasks]![Team_Sub_tasks_actions].Form!actionsteps
ExitLine:
Exit Sub
End Sub
Private Sub Form_Load()
ListTeam.Requery
ExitLine:
Exit Sub
End Sub
Private Sub Command14_Click()
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_Command14_Click:
Exit Sub
End Sub
Private Sub Command15_Click()
DoCmd.GoToRecord , , acNewRec
Exit_Command15_Click:
Exit Sub
End Sub
Private Sub Command19_Click()
DoCmd.Close
Exit_Command19_Click:
Exit Sub
End Sub
Private Sub Command21_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Agenda Prep"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command21_Click:
Exit Sub
End Sub
Private Sub Command22_Click()
Dim stDocName As String
stDocName = "Meeting Schedule"
DoCmd.OpenReport stDocName, acPreview
Exit_Command22_Click:
Exit Sub
End Sub
Private Sub Form_Open(Cancel As Integer)
Me!ListTeam.Requery
ExitLine:
Exit Sub
End Sub
Private Sub ListTeam_AfterUpdate()
Dim rst As DAO.Recordset
Dim strcriteria As String
strcriteria = "[taskid]= " & Str$(Nz(Me![ListTeam], 0))
Set rst = Me!Recordset.Clone
rst.FindFirst strcriteria
If rst.NoMatch Then
MsgBox "No entry found.", vbInformation
Else
Me.Bookmark = rst.Bookmark
End If
Set rst = Nothing
ExitLine:
Exit Sub
End Sub
List Box (that is located on the above form) Code
Option Compare Database
Option Explicit
Private Sub cmdAssignCal_Click()
txtAssignDate = CalendarDlg(txtAssignDate)
ExitLine:
Exit Sub
End Sub
Private Sub cmdDueCal_Click()
txtDueDate = CalendarDlg(txtDueDate)
ExitLine:
Exit Sub
End Sub
Private Sub Form_Current()
Me!TaskIDf =
Forms![team_top_sub_task]![Team_Sub_Tasks]![Team_Sub_tasks_actions].Form!TaskID
Me!Tasks =
Forms![team_top_sub_task]![Team_Sub_Tasks]![Team_Sub_tasks_actions].Form!actionsteps
ExitLine:
Exit Sub
End Sub
Private Sub Form_Load()
ListTeam.Requery
ExitLine:
Exit Sub
End Sub
Private Sub Command14_Click()
On Error GoTo Err_Command14_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_Command14_Click:
Exit Sub
End Sub
Private Sub Command15_Click()
DoCmd.GoToRecord , , acNewRec
Exit_Command15_Click:
Exit Sub
End Sub
Private Sub Command19_Click()
DoCmd.Close
Exit_Command19_Click:
Exit Sub
End Sub
Private Sub Command21_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Agenda Prep"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command21_Click:
Exit Sub
End Sub
Private Sub Command22_Click()
Dim stDocName As String
stDocName = "Meeting Schedule"
DoCmd.OpenReport stDocName, acPreview
Exit_Command22_Click:
Exit Sub
End Sub
Private Sub Form_Open(Cancel As Integer)
Me!ListTeam.Requery
ExitLine:
Exit Sub
End Sub
Private Sub ListTeam_AfterUpdate()
Dim rst As DAO.Recordset
Dim strcriteria As String
strcriteria = "[taskid]= " & Str$(Nz(Me![ListTeam], 0))
Set rst = Me!Recordset.Clone
rst.FindFirst strcriteria
If rst.NoMatch Then
MsgBox "No entry found.", vbInformation
Else
Me.Bookmark = rst.Bookmark
End If
Set rst = Nothing
ExitLine:
Exit Sub
End Sub
John
However, every time I add a new record successfully, a blank line gets added
to the list box. How can I prevent that from happening?
Below is the code I am using behind the form and behind the listbox on the
form:
Form Code (also, see listbox code below)
Option Compare Database
Option Explicit
Private Sub cmdAssignCal_Click()
txtAssignDate = CalendarDlg(txtAssignDate)
ExitLine:
Exit Sub
End Sub
Private Sub cmdDueCal_Click()
txtDueDate = CalendarDlg(txtDueDate)
ExitLine:
Exit Sub
End Sub
Private Sub Form_Current()
Me!TaskIDf =
Forms![team_top_sub_task]![Team_Sub_Tasks]![Team_Sub_tasks_actions].Form!TaskID
Me!Tasks =
Forms![team_top_sub_task]![Team_Sub_Tasks]![Team_Sub_tasks_actions].Form!actionsteps
ExitLine:
Exit Sub
End Sub
Private Sub Form_Load()
ListTeam.Requery
ExitLine:
Exit Sub
End Sub
Private Sub Command14_Click()
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_Command14_Click:
Exit Sub
End Sub
Private Sub Command15_Click()
DoCmd.GoToRecord , , acNewRec
Exit_Command15_Click:
Exit Sub
End Sub
Private Sub Command19_Click()
DoCmd.Close
Exit_Command19_Click:
Exit Sub
End Sub
Private Sub Command21_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Agenda Prep"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command21_Click:
Exit Sub
End Sub
Private Sub Command22_Click()
Dim stDocName As String
stDocName = "Meeting Schedule"
DoCmd.OpenReport stDocName, acPreview
Exit_Command22_Click:
Exit Sub
End Sub
Private Sub Form_Open(Cancel As Integer)
Me!ListTeam.Requery
ExitLine:
Exit Sub
End Sub
Private Sub ListTeam_AfterUpdate()
Dim rst As DAO.Recordset
Dim strcriteria As String
strcriteria = "[taskid]= " & Str$(Nz(Me![ListTeam], 0))
Set rst = Me!Recordset.Clone
rst.FindFirst strcriteria
If rst.NoMatch Then
MsgBox "No entry found.", vbInformation
Else
Me.Bookmark = rst.Bookmark
End If
Set rst = Nothing
ExitLine:
Exit Sub
End Sub
List Box (that is located on the above form) Code
Option Compare Database
Option Explicit
Private Sub cmdAssignCal_Click()
txtAssignDate = CalendarDlg(txtAssignDate)
ExitLine:
Exit Sub
End Sub
Private Sub cmdDueCal_Click()
txtDueDate = CalendarDlg(txtDueDate)
ExitLine:
Exit Sub
End Sub
Private Sub Form_Current()
Me!TaskIDf =
Forms![team_top_sub_task]![Team_Sub_Tasks]![Team_Sub_tasks_actions].Form!TaskID
Me!Tasks =
Forms![team_top_sub_task]![Team_Sub_Tasks]![Team_Sub_tasks_actions].Form!actionsteps
ExitLine:
Exit Sub
End Sub
Private Sub Form_Load()
ListTeam.Requery
ExitLine:
Exit Sub
End Sub
Private Sub Command14_Click()
On Error GoTo Err_Command14_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_Command14_Click:
Exit Sub
End Sub
Private Sub Command15_Click()
DoCmd.GoToRecord , , acNewRec
Exit_Command15_Click:
Exit Sub
End Sub
Private Sub Command19_Click()
DoCmd.Close
Exit_Command19_Click:
Exit Sub
End Sub
Private Sub Command21_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Agenda Prep"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command21_Click:
Exit Sub
End Sub
Private Sub Command22_Click()
Dim stDocName As String
stDocName = "Meeting Schedule"
DoCmd.OpenReport stDocName, acPreview
Exit_Command22_Click:
Exit Sub
End Sub
Private Sub Form_Open(Cancel As Integer)
Me!ListTeam.Requery
ExitLine:
Exit Sub
End Sub
Private Sub ListTeam_AfterUpdate()
Dim rst As DAO.Recordset
Dim strcriteria As String
strcriteria = "[taskid]= " & Str$(Nz(Me![ListTeam], 0))
Set rst = Me!Recordset.Clone
rst.FindFirst strcriteria
If rst.NoMatch Then
MsgBox "No entry found.", vbInformation
Else
Me.Bookmark = rst.Bookmark
End If
Set rst = Nothing
ExitLine:
Exit Sub
End Sub
John