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
Solved

Requery

Posted on 2011-09-29
6
367 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
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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

837 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