Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / February 2005

Tip: Looking for answers? Try searching our database.

Use Re-query  and RepaintObject Action

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
iholder - 28 Feb 2005 18:39 GMT
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.
Dirk Goldgar - 28 Feb 2005 18:49 GMT
> 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 -----
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.