Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7915089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:20:33+00:00 2026-06-03T14:20:33+00:00

So in my Access application, there’s a field where the user selects a name

  • 0

So in my Access application, there’s a field where the user selects a name from a dropdown list, or types one. The list should return a number (the PersonID of the person selected, if in the People table) or a string (if entering the name of someone not in the DB).

This must be a fairly common requirement, but I don’t see any very simple way to do it. The way that first occurs to me is to have VBA code which, if the user types a name instead of selecting from the list, creates an entry in the People table for the new person and then returns his PersonID (newly assigned by AutoNumber). This would presumably involve a dialog interrogating the user for required information (e.g. phone number) about the new person.

Is there a better way? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:20:35+00:00Added an answer on June 3, 2026 at 2:20 pm

    Use the NotInList event of the ComboBox. Here is a quick sample:

    Private Sub PersonID_NotInList(NewData As String, Response As Integer)
    Dim Result As VbMsgBoxResult, NewPersonID As Long, MaxPersonID As Long
    
        On Error GoTo Err_PersonID_NotInList
    
        Response = acDataErrDisplay
        Result = MsgBox("'" & NewData & "' is not currently in the database.  " & _
                        "Would you like to add '" & NewData & _
                        "' to the database?", vbYesNo + vbExclamation, _
                        "Person Not In List")
        If Result = vbYes Then
            MaxPersonID = DMax("PersonID", "People")
            DoCmd.OpenForm "AddPerson", , , , acFormAdd, acDialog, NewData            
            NewPersonID = DMax("PersonID", "People")
            If NewPersonID > MaxPersonID Then
                Me.PersonID = NewPersonID
                Me.PersonID.Requery
                Response = acDataErrAdded
            End If
        End If
    
    Exit_PersonID_NotInList:
        Exit Sub
    Err_PersonID_NotInList:
        MsgBox Err.Description
        Resume Exit_PersonID_NotInList
    End Sub
    

    NOTES:

    • Using DMax is not a reliable way to get the newly added PersonID, but it makes the sample easier to read. You should use SELECT @@Identity instead (Google for more info).
    • I passed NewData as an OpenArg to the “AddPerson” form. This would allow you to pre-populate the person’s name when opening the AddPerson form.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started using the Data Access Application Block from microsoft. There are
In one of my CI application there is an user login section. The users
Is there any way for a web application to access the location data of
There I am writing a Python application on win7. I would like to display/access
My current backbone application has a url: localhost/#users Is there a way to access
We are planning to redesign quite a huge MS Access application. Is there any
I have an Access application where everytime a user enters the application, it makes
I have a MS Access application and have problem to find a return type
In my application there is a login page after login the user will get
I'm trying to launch another program install in my system from my Access application.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.