Solved

Requery

Posted on 2011-09-29
6
363 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

821 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