Am I using these actions correctly. I am not achieving the correct results.
The main form is "frmEmployeeLabels" . On this form is a command add button
to add a new employee. add button code:
Private Sub cmdAdd_Click()
On Error GoTo Err_cmdAdd_Click
Dim stDocName As String
stDocName = "frmAddEmployees"
DoCmd.OpenForm stDocName, , , , acFormAdd
Exit_cmdAdd_Click:
Exit Sub
Err_cmdAdd_Click:
MsgBox Err.Description
Resume Exit_cmdAdd_Click
End Sub
On this form the "close form button" code is:
Private Sub cmdCloseForm_Click()
On Error GoTo Err_cmdCloseForm_Click
Dim ctlFullName As Control
' Return Control object pointing to a text box.
Set ctlFullName = Forms!frmEmployeelabels!FullName
' Requery source of data for list box.
ctlFullName.Requery
DoCmd.RepaintObject acForm, "frmEmployeelabels"
DoCmd.Close
Exit_cmdCloseForm_Click:
Exit Sub
Err_cmdCloseForm_Click:
MsgBox Err.Description
Resume Exit_cmdCloseForm_Click
End Sub
I am trying to update query list on main "frmEmployeeLabels" after an
employee is add from the add employee form.
New employee added does not appear only after closing and opening the main
form.
Help needed with correct coding.
Thank you.
> Am I using these actions correctly. I am not achieving the correct
> results.
[quoted text clipped - 49 lines]
>
> Thank you.
I think what you want to do is just requery frmEmployeeLabels in the
Close event of frmAddEmployees:
'----- start of suggested code -----
Private Sub cmdCloseForm_Click()
On Error GoTo Err_cmdCloseForm_Click
If CurrentProject.AllForms("frmEmployeeLabels").IsLoaded Then
Forms!frmEmployeeLabels.Requery
End If
Exit_cmdCloseForm_Click:
Exit Sub
Err_cmdCloseForm_Click:
MsgBox Err.Description
Resume Exit_cmdCloseForm_Click
End Sub
'----- end of suggested code -----

Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
iholder - 28 Feb 2005 19:47 GMT
Thank you
Dirk,
I add one more line to your code before the re-query.
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
It works just fine.
> > Am I using these actions correctly. I am not achieving the correct
> > results.
[quoted text clipped - 72 lines]
>
> '----- end of suggested code -----