?
Solved

Run Time Error 2450

Posted on 2009-07-10
5
Medium Priority
?
334 Views
Last Modified: 2013-11-28
I've got a data entry form: frm_Log with a combo box for clientID: ComboClientID and a combo box for Staff: ComboStaffSignature
When a new client or a new staff has to be entered, I've got a command buttons that open either frm_Client or frm_Clinicians
When those forms close, I want the respective combo box to update, and so have this code on the form close:
Private Sub Form_Close()
     Forms!frm_Log![ComboStaffSignature].Requery
End Sub
Private Sub Form_Close()
     Forms!frm_Log![ComboClientID].Requery
End Sub
but am getting the error code 2450 .....can't find the form 'frm_Log' referred to...but it does exist
0
Comment
Question by:schneider_ks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 39

Accepted Solution

by:
thenelson earned 750 total points
ID: 24824515
In the form close event, the table is already unloaded so the requery fails. Move your code to the form unload event.

The combobox not in list event has features built in to simplify this: NewData And Response.

NewData    A string that Microsoft Access uses to pass the text the user entered in the text box portion of the combo box to the event procedure.

Response    The setting indicates how the NotInList event was handled. The Response argument can be one of the following intrinsic constants:

Constant Description

acDataErrDisplay (Default) Displays the default message to the user. You can use this when you don't want to allow the user to add a new value to the combo box list.

acDataErrContinue Doesn't display the default message to the user. You can use this when you want to display a custom message to the user. For example, the event procedure could display a custom dialog box asking if the user wanted to save the new entry. If the response is Yes, the event procedure would add the new entry to the list and set the Response argument to acDataErrAdded. If the response is No, the event procedure would set the Response argument to acDataErrContinue.

acDataErrAdded Doesn't display a message to the user but enables you to add the entry to the combo box list in the NotInList event procedure. After the entry is added, Microsoft Access updates the list by requerying the combo box. Microsoft Access then rechecks the string against the combo box list, and saves the value in the NewData argument in the field the combo box is bound to. If the string is not in the list, then Microsoft Access displays an error message.

0
 
LVL 85
ID: 24824526
Is the Log form actually named "frm_Log", and is it open at the time? Your code would only work if those two conditions are True.

Also, are these combos on a SUBFORM?

FWIW, I use this syntax:

Forms("frm_Log").ComboStaffSignature.Requery

Either way will work, but as the Combo is part of the controls Collection, you really should refer to it with a Dot ( . ) instead of a Ban ( ! ).
0
 
LVL 85
ID: 24824541
I agree with Nelson regarding the NotInList, but it's quite common to open a form when this event is triggered ... often you don't simply add a single line of data to a new record, and you often need to allow the user to enter other data items.

0
 

Author Closing Comment

by:schneider_ks
ID: 31602083
Thanks!  I moved the code to the unload event, and it's working.  Sorry, but I didn't understand the rest of your comments.
0
 
LVL 39

Expert Comment

by:thenelson
ID: 24826573
You're welcome.  Glad to help.

The usual place records are added to a combobox is in the combobox not in list event. It has features designed to simplify the process.

Happy Computing!

Nelson
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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 …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

752 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