Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
| Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 4th, 2004, 03:08 PM
lxu lxu is offline
Authorized User
 
Join Date: Oct 2003
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default Retrieve new entry without closing/reopening Form

There are a combo box and button “Create” on Form_1. Clicking on the button, the Form_2 which is used to create a new record is opened. After a new record is entered, the Form_2 is closed.

Problem: The new record just entered cannot be found in the combo box of Form_1. It will show there only after closing/reopening Form_1

How to make it without closing/reopening the form?

Thanks in advance,

LX


 
Old April 4th, 2004, 04:45 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Melbourne, Vic, Australia.
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try refreshing or requerying the combo box when Form_2 is closed.

So you'll have something like this in Form_2:
Code:
Private Sub Form_Close()
cbxSomething.Requery
End Sub
I am a loud man with a very large hat. This means I am in charge
 
Old April 4th, 2004, 04:46 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Melbourne, Vic, Australia.
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Of course, you'll have to define what form cbxSomething is on, so you'll really have:
Code:
Private Sub Form_Close()
Form_Form_1.cbxSomething.Requery
End Sub
I am a loud man with a very large hat. This means I am in charge
 
Old April 5th, 2004, 11:39 AM
lxu lxu is offline
Authorized User
 
Join Date: Oct 2003
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It works perfectly! Thanks.

Lx

 
Old April 9th, 2004, 10:27 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I got around this problem another way. I have two forms that I switch back and forth between to enter new records. The buttons that I use to open the new form has this line before the code to open the new form:

DoCmd.Close

Then when the record is added in the second form, the button to go back does the same thing. This automatically requeries the opening form, of course.

This assumes you want to click a button each time. But I find it keeps the work area less cluttered having only one form open at a time.


mmcdonal
 
Old April 29th, 2004, 01:16 PM
lxu lxu is offline
Authorized User
 
Join Date: Oct 2003
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

After creating the new record in Form-2, close the form by clicking on button click. The key field of the new record is added in the combo box in Form-1. How to set the new one to be selected in combo box and display data of other fields in form-1 automatically?

I add the following codes in form-2
Private Sub newClsClose_Click()
     Forms![Form-1].Requery
     Forms![Form-1].[cbx].Requery 'combo box requery

     'Find the record that matches the control
     Dim rs As DAO.Recordset

     Set rs = Forms![Form-1].Recordset.Clone

     rs.FindFirst "[Class-Name] = '" & Me.Input_Name & "'"
     If Not rs.EOF Then Forms![Form-1].Bookmark = rs.Bookmark

     Forms![Form-1]![cbx].Value = Me!Input_Name

     DoCmd.Close
End Sub

It is failed to display the new record in Form-1 since I cannot find the new record in the RecordsetClone. There is anything wrong?

Thanks for any suggestion.

chrislx





Similar Threads
Thread Thread Starter Forum Replies Last Post
closing a form mnvijay VS.NET 2002/2003 4 December 18th, 2007 07:20 AM
Form closing bschleusner C# 2005 2 February 4th, 2007 04:07 PM
How to refresh owner form on closing of child form akumarp2p C# 2005 0 December 22nd, 2006 10:27 AM
Closing a form after opening another form rosebushr Access 2 January 7th, 2006 04:34 AM
closing Form kobystud C# 4 July 1st, 2004 03:34 PM





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