NotInList go to New Record

Garindan

Registered User.
Local time
Today, 06:51
Joined
May 25, 2004
Messages
250
Hi all, I apologize if this has been answered many times, but i couldn't find the answer when searching.

It's probally pretty simple. I have a form with a combo box at the top used to find customers on the form. It is used to navigate to a customer and also check if a customer already has a record. When a customer is selected from the combo it goes to their record, simple. All i wanted to do was use the NotInList event to tell the combo box to go to a new record (on the same form) when a customer is entered and doesnt have an existing record.

I have tried doing it with a macro (my knowledge doesn't extend to code yet :rolleyes: ) but i can't get it to work. I had the macro as NotInList - GoToRecord - object type: form - object name: 'name of same form' - record: new................ but it doesn't seem to work, the combo box will go back to the first record instead. Sorry, i'm learning.

Anybody know how i can do it?? Thanks for your help.

Lee.
 
Make sure that you combo box property "Limit to list" = Yes

I have tried it but i am getting errors to try and make it go to a new records, but i am using A97 and code and not a macro.

So it may work for you.

But you can not use the NotInList command unless this property is Yes

Hope this helps.
 
Hi M8KWR, thanks for the help. I had only realised about the limit to list = yes thing about half an hour ago, so i tried it too, but it seems to be the same as yours, it either doesn't work at all or i get an error message :confused:

Any more ideas? Thanks alotfor your help :)
 
Try This

Garindan, I have modified my database to post. Enter an obscure Vehicle Make that is not in the list - Add To List at Prompt - Then TAB. Type in a Model and ADD when prompted.

Hope that is what you are after. If not you may be able to modify to suit your requirements.

I'm off to bed.....good luck!
Phil.
 

Attachments

Hi mate, thanks. Unfortunately i think its a bit over compicated for me. All i was trying to do is when you enter a customer surname that's not in the list, have the form (same form) go to a new record, so you can enter the customers full details (name, address, etc). It sounds simple, but i dont know how. Any other idea's?
 
Typed not tested - in your not in list event, you could try the following. To enter the event procedure, remove the macro name, hit the button with three dots, and paste the following code

response=acdataerrcontinue ' remove default not in list message
msgbox "customer doesn't exist - new record"
me!cboNameOfYourCombo=Null ' undo selection in combo
me.undo ' undo changes of the record, remove if not necessary
docmd.gotorecord,,acnewrec

Alter the combo name to match your combo.
 
Last edited:
Thanks alot Roy!! :D That worked a treat!!!!!! :D

I had to delete the 'cbo' part of 'me!cboNameOfYourCombo' aswell as put name of combo (obviously) but then it worked perfectly. Thanks again, thats brilliant! :cool:
 
You're welcome!

Short comment on the cbo part of the name - it's part of a naming convention used by most developers where every control one refer to either in controlsources or through code, get's a prefix indicating what kind of control it is, txt for text controls, cbo for comboboxes, cmb for commandbuttons...
 
Ok thanks. Used naming conventions for tables, forms, queries, etc, aswell as field names, but not for controls yet :o
 

Users who are viewing this thread

Back
Top Bottom