Solved

Requery

Posted on 2011-09-29
6
358 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
  • 3
  • 3
6 Comments
 
LVL 14

Expert Comment

by:pteranodon72
Comment Utility
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
Comment Utility
(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
Comment Utility
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 14

Accepted Solution

by:
pteranodon72 earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you very much. It works great
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now