Solved

Requery

Posted on 2011-09-29
6
373 Views
Last Modified: 2012-06-22
I have a form called “Scheduling-Add” in my database. This form Has 2 buttons “PatientName” & “Studies” when clicked, another form will open up that can be used to add a new patient or new studies respectively. Upon adding a new patient or studies I want their respective pull downs to be requeried were the user can see the new patient name or new studies name that was added without closing the form and opening it before seeing the new additions. Attached is a copy of my database with the form.
Invoice-7-7-2001-91611.accdb
0
Comment
Question by:Chrisjack001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 14

Expert Comment

by:pteranodon72
ID: 36818557
To do this properly, the main form needs to know when records have been added (or nothing was added). Right now, the name entry form opens at the button push, but the user can switch back to the main form, work for twenty minutes, add a record to the patient form. Use the acDialog argument to make the Patient form open modally -- it must be closed before any other work can be done in Scheduling.


Private Sub cmdPatientName_Click()
DoCmd.OpenForm "Patients", , , , acFormAdd, acDialog
'code waits until Patients form is closed
cmbPatientName.Requery
End Sub

Private Sub cmdStudyId_Click()
DoCmd.OpenForm "Studies-Add", , , , acFormAdd, acDialog
'code waits until Studies-Add form is closed
StudyID.Requery
End Sub

HTH,

pT72
0
 
LVL 14

Expert Comment

by:pteranodon72
ID: 36818590
(If you remove the acDialog argument, the Requery method fires immediately after the other form is opened, before any new records are added. )
0
 

Author Comment

by:Chrisjack001
ID: 36892042
Hi pteranodon72, Im kind of confused. Are we talking about the same form. You keep referring to the main form and entry form but the form I need help with is the "Scheduling-Add" form. Can you please clarify if thats the same form you are talking about. Can you please make changes on the form in the sample database I attached and please send it back.Thanks
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 14

Accepted Solution

by:
pteranodon72 earned 500 total points
ID: 36892432
chrisjack001,
I'm happy to discuss the (tested) code change and clarify, but I won't edit and repost the file.

Open the form "Scheduling-Add" in Design view and view the code module.  Please replace the existing code:

Private Sub cmdPatientName_Click()
DoCmd.OpenForm "Patients", , , , acFormAdd
End Sub

with:
Private Sub cmdPatientName_Click()
DoCmd.OpenForm "Patients", , , , acFormAdd, acDialog
'code waits until Patients form is closed
cmbPatientName.Requery
End Sub

Open in new window


and replace:
 
Private Sub cmdStudyId_Click()
DoCmd.OpenForm "Studies-Add", , , , acFormAdd
End Sub

with:

Private Sub cmdStudyId_Click()
DoCmd.OpenForm "Studies-Add", , , , acFormAdd, acDialog
'code waits until Studies-Add form is closed
StudyID.Requery
End Sub

Open in new window


In earlier posts, the "main form" I referred to was Scheduling-Add. It has two buttons that open up Patients and Studies-Add. In each case, you want to open Patients or Studies-Add modally, waiting for them to close before requerying the combo box.

HTH,
pT72
0
 

Author Comment

by:Chrisjack001
ID: 36892500
By doing this will they automatically requery where they can be seen in the drop down without closing the form and reopening?
0
 

Author Closing Comment

by:Chrisjack001
ID: 36892559
Thank you very much. It works great
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question