Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I populate a combo box with new records?

Status
Not open for further replies.

ledwards

IS-IT--Management
Aug 3, 2000
6
0
0
US
I have two forms Enrollment and Customer.&nbsp;&nbsp;On the Enrollment Form I have a combo box which list all my customers.&nbsp;&nbsp;I have a customer name new customer.&nbsp;&nbsp;When a user selects the new customer record from the combo box(CmbCustomer) the Customer form opens in data entry mode.&nbsp;&nbsp;A new customer is created.&nbsp;&nbsp;On the close of the Customer form I would like to fill in the newly created customer in the combo box.&nbsp;&nbsp;I attemp to do this by creating an event on the close of the Customer form to do the following Form!EnrollmentForm!CmbCustomer = Me!CustomerID.&nbsp;&nbsp;Which results in a blank combo box since it has not been refreshed yet.&nbsp;&nbsp;I've tried to do a requery on the combo box, which give me the action isn't currently available error message.&nbsp;&nbsp;Help?<br><br>There's got to be an easy way to do this.&nbsp;&nbsp;Thanks in advance.<br>
 
Try something like this:<br><br>'If some form is open, close this form and<br>&nbsp;&nbsp;&nbsp;&nbsp;'return focus to that form.<br>&nbsp;&nbsp;&nbsp;&nbsp;If IsLoaded(&quot;SomeForm&quot;) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim X As Variant<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X = Me![ComboField]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.Save acForm, &quot;ThisForm&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.Close 'acForm, &quot;ThisForm&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Forms!SomeForm![ComboField].Requery<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DoEvents<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Forms!SomeForm![ComboField] = X<br>&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;'Otherwise, close this form and return to the Main Menu.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.Close<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br><br>Hope this helps.<br><br>Lightning<br>
 
Thanks Lightning it work great.&nbsp;&nbsp;Lester <p>ledwards<br><a href=mailto:ledwards@cnyworks.com>ledwards@cnyworks.com</a><br><a href= Works</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top