[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Requery

Posted on 2011-09-29
6
Medium Priority
?
380 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 14

Accepted Solution

by:
pteranodon72 earned 2000 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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

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.
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

650 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