Add a new form if combo shows error not in list (1 Viewer)

Hoffy18

New member
Local time
Today, 12:09
Joined
Feb 8, 2023
Messages
2
I have been an access user since 2.0. I retired 10 years ago and have been asked to build a new database for a animal rescue group. I am using 365 and will put on SharePoint. I have forgotten much and new access is different. So here is my problem and I can’t find the exact code needed. Can someone help please?
I have a form with an unbound combo field that looks up the last name of stuff already in there. It’s great. When I put in a name that is not on the list, I get the error message. But I don’t want to add to that combo box, I want it to go to a New form, to answer all the data questions there. I might be getting too old to do this. Thank you.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 17:09
Joined
Feb 19, 2013
Messages
16,614
On my phone but if you look at the combo properties the is one for ‘ not in list’
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:09
Joined
Oct 29, 2018
Messages
21,474
Hi. Welcome to AWF!

Another one of the properties to investigate is the List Items Edit Form.
 

tvanstiphout

Active member
Local time
Today, 09:09
Joined
Jan 22, 2016
Messages
222
Many versions ago we would add the new record using code in the combobox' NotInList event. Nowadays there is a zero-code option: see the Limit To List, Allow Value List Edits, and List Items Edit Form properties. Using F1 key you can get help on each of these properties.
Edit: For an example, download the new Northwind Dev Edition template (File > New) and check out the Customer dropdown on the OrderDetails form.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:09
Joined
Feb 28, 2001
Messages
27,187
The general idea is that in a "not in list" case you enter a value into the combo and it gives you the "NotInList" event. In the event code, you open (as a pop up) this new form and let it do its data-entry thing. You close the pop-up form. Now focus should return back to the same "NotInList" code just after you opened the PopUp. So you tell the combo to do a requery (to detect the new entry) and you can then do the selection using the new data.


You can find examples and other information by searching this forum or the general web for Combo Not In List Event
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 12:09
Joined
Feb 19, 2002
Messages
43,275
@Hoffy18 You've been around for a while but this is your first post. Nice to hear from you. Welcome.

As the others mentioned, the NotInList property will allow you to specify the name of a form to open so you can add multiple attributes rather than just the name.

Personally, I try very hard to not allow the users to add items on the fly this way. Some users are way too sloppy and/or can't spell so you have a fair chance of ending up with garbage. My preference is to create an interface that only an "admin" can use to add new items. Of course it all comes down to the frequency with which you have to add new items and the spelling ability of your average user;)
 

Users who are viewing this thread

Top Bottom