Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 25th, 2005, 11:06 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 126
Thanks: 5
Thanked 0 Times in 0 Posts
Default Calling a procedure embeded in another form

Hello all,
I need some assistance please.
Here is the situation:
I have an RFQ form open. On that form is a button to add your name to a drop down list. The button pulls up an 'addinitiator' form for them to type in their name. When the are done typing in their name, they click on the ok button and the form closes and takes them back to the RFQ form. What I want it to do is immediatly after closing the addinitiator form, I want the drop down list in the other form to update. If my code on the ok button to close the addinitiator form is simply "docmd.close acform,'Addinitiator'", and in the RFQ form module I have a prodecure as follows:
Private Sub InitiatorUpdate()
Initiator.SetFocus
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acRefresh
End Sub
What do I add to the close command to make it run the Initiator update procedure?

Any help is greatly appreciated!

Regards,
Laura

The only thing standing between you and your goal is doubt. Quit doubting yourself and you'll be able to accomplish anything!
__________________
Regards,
Laura

The only thing standing between you and your goal is doubt. Quit doubting yourself and you'll be able to accomplish anything!
 
Old April 25th, 2005, 11:36 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

   A very simple way to do this is to close the RFQ form when you open the AddInitiator form. Just add a line like this:

'=====
... ' your code

DoCmd.Close
DoCmd.OpenFrom, stDocName (AddInitiator Form) etc
'=====

Then make the close button on the AddInitiator form reopen the RFQ form, and the combo box will be synched.

There are other ways to do this (search Help for "synchronize forms") but I use this method to keep the user from getting too many forms open on the page. Just one form at a time is my rule.

HTH


mmcdonal
 
Old April 25th, 2005, 11:47 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 126
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Thank you for your suggestion. Unfortunately, I cannot have it close the RFQ form because of the many required fields. If I close the form, the users will be very unhappy that they have lost their information.

Any other ideas?

Regards,
Laura

The only thing standing between you and your goal is doubt. Quit doubting yourself and you'll be able to accomplish anything!
 
Old April 25th, 2005, 01:04 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Suppose the dropdown list in the RFQ form is called cboMyDropdown. Then when you close the addinitiator form, on that form's ON CLOSE event, put

Forms.[Name of RFQ Form Here].Form.cboMyDrowndown.Requery



Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old April 25th, 2005, 01:12 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 126
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Worked like a charm...Thank you so much!

Regards,
Laura

The only thing standing between you and your goal is doubt. Quit doubting yourself and you'll be able to accomplish anything!
 
Old April 25th, 2005, 05:08 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

“The only thing standing between you and your goal is doubt. Quit doubting yourself and you'll be able to accomplish anything!”

Frankly, I doubt it... It is unlikely that suspending my doubt would allow me suddenly to be elected to a high political office (as just one of myriad such examples). Just for what it’s worth...
 
Old April 29th, 2005, 08:48 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:Frankly, I doubt it... It is unlikely that suspending my doubt would allow me suddenly to be elected to a high political office (as just one of myriad such examples). Just for what it’s worth...
But Brian, do you want to be elected to a high political office? If that's what you want,
Quote:
quote:Quit doubting yourself
:D

BTW, another option to all of this would be to use the "NotInList" event. If someone enters a name not in the list, you could popup your addinitiator form (do it Modal so the form must be closed before they can do anything else). When the form is closed, set

Response = acDataErrAdded

Response is a parameter of the NotInList event. acDataErrAdded will automatically refresh the dropdown list.

And if all you are doing is adding a name to your initiator lookup table, you could even take that all a step further by simply adding the initiator without the user having to see a form. In the NotInList...

strSQL = "INSERT into [initiatortable] SET ([Initiator]) VALUES (""" & Me.cboMyDropDown & "")"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
Response = acDateErrAdded

Note: this assumes Me.cboMyDropDown will never have a quote in it.

The one problem with this is that it doesn't slow people down enough to see if they made a typo. So, change that to...

strMsg = """" & Me.cboMyDropDown & """ is not a valid initiator." & vbcrlf & vbcrlf
strMsg = strMsg & "Do you wish to add it?"
if vbYes = MsgBox(strMsg, vbQuestion + vbYesNo, "Add Initiator") then
    ... the code above ...
else
    Response = acDateErrContinue
End If

Advantage: Don't need that damn addinitiator form anymore. Which means... one less thing to maintain.:D

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org





Similar Threads
Thread Thread Starter Forum Replies Last Post
calling stored procedure jomet JSP Basics 0 November 23rd, 2007 08:06 AM
Calling on a database within a stored procedure Hadware SQL Language 1 January 8th, 2007 05:11 PM
Calling Stored Procedure Using vc++ senthil_mano Visual C++ 0 August 30th, 2006 12:20 AM
Calling Stored Procedure with parameters zarina_24 Classic ASP Professional 4 March 2nd, 2006 11:57 AM
Calling a procedure within a data repeater DittoToo ASP.NET 1.0 and 1.1 Basics 0 July 15th, 2003 02:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.