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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is there a way?

Status
Not open for further replies.

Onslaughtdave

Programmer
Jan 24, 2005
59
CA
Hi,

Is there a way to discover which events are firing as i do things?

in the case that there isn't this is what im tring to do:

there is a combo box with a bunch of stuff. if they type one in and find that it isnt in the list then there is an add button beside it. if they press the add button it will open my maintanence form so they can add in the correct record and then it dumps them back. BUT when i try to click on the add button i get an error cause im trying to enter a non existant recrod into the combo box. is there a way to trap this and find out where this error msg is firing so i can replace it with some other code that will fix the problem?

thanks,

Dave
 
Do it something like this:
Code:
If (Msgbox("Item doesn't exist.  Do you want to Add it?",vbYesNo+vbQuestion) = vbNo) then

    Response = acDataErrContinue
    ctlComboBox.Undo

else
    DoCmd.OpenForm "FormName", , , , acAdd, acDialog

    If (gbolRecordAdded) Then
        
        Response = acDataErrAdded
    
    Else
        
        Response = acDataErrContinue
        ctlComboBox.Undo
    
    End If

End If
Note that the form was opened as a dialog form (acDialog). That's because you don't want your code to execute until the user exists the form. Note also that the user could cancel adding the record. If so, no need to requery the combobox. That's why I check the global variable gbolRecordAdded. In the OnOpen event of the form I set it to false. In the AfterInsert event of the form I set it to true.
 
FancyPrairie,

where do i put that? it wont let me click off the text field so i cant press anything.

what trigger is catching this?
 
Take a look at the NotInList event procedure and the LimitToList property of the ComboBox object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Set the LimitToList property of the combobox to Yes. Set the NotInList property of the combobox to [Event Procedure]. Then click on the elipses (...) beside it. A module will open. Copy and paste the above code into the module

Also, look at help for notinlist.
 
By the way, this eliminates the need for your command button. You can get rid of it.
 
yes!

ok thanks that did the trick!

thanks for your help...

PHV and FancyPrairie.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top