[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Requery a form that is already open in Access 2003

Posted on 2007-07-31
14
Medium Priority
?
1,257 Views
Last Modified: 2013-11-28
I have a main form that I have put a VB control on to go to open up another form with has password to open it in the open form event. If I put Docmd.close on this cmd button it closes the form before the other form opens. If the user does not put the right password in the current form is also closed.

What I am looking to do is when I am in the second form that required the password and i click on the cmd button to clsoe that form it will requery the original form
0
Comment
Question by:Pdeters
  • 7
  • 7
14 Comments
 
LVL 10

Expert Comment

by:aesmike
ID: 19603528
Forms!OriginalForm.requery
0
 

Author Comment

by:Pdeters
ID: 19603594
Where should I put this. I put it in the event of the cmd button to close the 2nd form
0
 
LVL 10

Expert Comment

by:aesmike
ID: 19603674
Explain the flow of how you want it to work a little more.  Sounds like you have a main form and a 2nd form.  The 2nd form is password protected.  You have a button on the main form that opens the 2nd form.  If the 2nd form opens successfully, what happens to the main form?  stays open or gets closed?
Eventually the 2nd form gets closed.  There's a button on this 2nd form to close it?  If 2nd form closes, it sounds like you want the main form to be requeried.  If that's the case, I assume the main form is to remain open all the time.  That being the case, put the Requery command in the OnClose event of the 2nd form.  That way it fires off if the user clicks the button or clicks the "X" at top right.
In any event, before requerying the main form you should check to make sure it's still open (a user could close it accidentally)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:Pdeters
ID: 19603677
I also have some combo boxes that you can select the record that you want .

0
 

Author Comment

by:Pdeters
ID: 19603952
What code could i put in the 2nd form to close and then reopen the first form
0
 
LVL 10

Expert Comment

by:aesmike
ID: 19604011
what's the intent behind closing and reopening the first form?  (other than to requery it if it's already open)
0
 

Author Comment

by:Pdeters
ID: 19608962
It doesn't seem to be requery - I have a combo box that you select the record you want. This is not requeying
0
 
LVL 10

Expert Comment

by:aesmike
ID: 19611699
I don't mean to sound dense, but can you explain , from the top, how you would like your application to work (e.g. "I click here and this happens, I close this and this should happen, etc")
0
 

Author Comment

by:Pdeters
ID: 19612256
Not a problem and you are not the dense one - (That would be me)

This is what I am looking for
My main form "HospitalForm" - the name of the hospital is locked on the form so it does not accidentally get changed - so for the main user to be able to change it I created a form that she could go to to be able to change the name and address of the hospital - they want no one else to have access to this so I created a form that required a password to open. - i put the code in the "OnOpen" event in the subform.

So after the informaiton is updated in the subform I would like to be able to go back to the main form and have it updated there - If I just requery the drop downs that are used to choose a record are not changed until you close and reopen the form.

If I put a Docmd.Close on the command button that goes to the subform it closes before the person has to put in the password and then if they put in the wrong password they are not in any form any longer but but back to a Switchboard. I would like if possible that if they are not able to put in the correct password to the subform that they remain in the main form.

Am I making sense??
0
 
LVL 10

Expert Comment

by:aesmike
ID: 19612457
Ok, makes more senese, however the part you left out is that you are closing the main form somewhere.  Is the reason you are closing the main form is to get this combo box to show the correct value?

2nd question: Can the 2nd form be opened Modally, as a dialog box?
3rd Question: The hospital name is displayed in a combo box on the hospital form, correct?  A user can change this to another hospital but they can't change the actual name of the currently displayed hospital unless they go into this 2nd form, correct?
4th question: The combo box that displays the names of hospitals, is there some hospital id or something other than the name that's a key field?
0
 
LVL 10

Accepted Solution

by:
aesmike earned 2000 total points
ID: 19612775
The approach I'm thinking of is this:
From the hospital form, user clicks a button to launch the 2nd form.  The onClick event of Hospital form opens the 2nd form modally (e.g. docmd.OpenForm "blah blah",,,,,acDialog)
When you do this, the code in the hospital form stops at the OpenForm line and waits until the 2nd form is closed.  Now, the code in the hospital form continues to the next line which would refresh the hospital name.  You shouldn't have to close the hospital form and reopen just because you want to see the new name.  If you do, then we have to talk about how your hospital name is displayed and come up with the answer to that.
0
 

Author Comment

by:Pdeters
ID: 19617955
Questions
1- Yes - I am wanting to refresh
2 - Sorry but am not really sure what you mean by second qeustions.
3 - Yes hospital name is displayed in combo box to choose hospital - correct - they can change to another hospital but can not change the name of the hospital
4 - the key fieild is an id field - is in the combo box bu they do not see it
You approach sounds like exactly what I am looking for. Right now I have a button that launches the 2nd form - this is the code on the on click event of the button

Private Sub cmdChangeHospital_Click()
On Error GoTo Err_cmdChangeHospital_Click
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "qryHospitalChangeName"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdChangeHospital_Click:
    Exit Sub

Err_cmdChangeHospital_Click:
    MsgBox Err.Description
    Resume Exit_cmdChangeHospital_Click
   
End Sub
0
 

Author Comment

by:Pdeters
ID: 19649603
Sorry it took me so long to get back to this. Thanks!!

Patty
0
 
LVL 10

Expert Comment

by:aesmike
ID: 19649618
you're welcome.  So it worked?
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
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.
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.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Suggested Courses

834 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