Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2003
    Location
    Laredo, TX
    Posts
    6

    Question Unanswered: Is a drop-down list box = combo box ?

    I'm starting to use MS Access ..

    I'm using some combo boxes.. only with the data on the tables...
    but I dont want the user to be able to write anything on the box..

    it does work because it shows a message that says 'the text you entered is not an item on the list.." but I dont want this message
    to appear..

    also, is there a way to prevent or customize this alert or error windows.

    thanks in advance..

  2. #2
    Join Date
    Nov 2002
    Location
    Melbourne
    Posts
    92
    Try this


    Add this in the NotInList event on the combo box.

    Private Sub Nationality_NotInList(NewData As String, response As Integer)
    If IsNull(NewData) Or NewData = vbNullString Then Exit Sub
    If MsgBox(NewData & " does not exists in the table. Would you like to add it now?", vbYesNo + vbQuestion, "Nationality....") = vbYes Then
    response = acDataErrAdded
    DoCmd.RunSQL ("INSERT INTO tblNationality (Nationality) VALUES ('" & NewData & "');")
    Else
    response = acDataErrContinue
    Nationality.Undo
    End If
    End Sub

    This is the customized message that I use when a value entered in the combobox that is not in the table.

    Hope this helps.

    There many be others on this forum who may make some other suggestions if my suggestion doenst work for you.
    Last edited by billjov; 08-06-03 at 23:09.

  3. #3
    Join Date
    Aug 2003
    Location
    Laredo, TX
    Posts
    6

    Thumbs up

    Hi... thanks for writing so fast..

    It did work better than the cmd.setwarnings false
    that one didnt work.. I placed on the NotInList event
    maybe I'm doing something wrong..

    The code that you sent me, worked fine.. but I still dont
    want anyone to write on the list..
    and if I eliminate the line Docmd.RunSQL.... it does the same..

    thanks again...

  4. #4
    Join Date
    Nov 2002
    Location
    Melbourne
    Posts
    92
    Ok I think I know what u are trying do know.

    You basically want something similar to the code I gave u without any data being add.

    I tried various things but I just couldnt seen to get to do exactly what you want.

    I think someone with a bit more no how will have to help u on this one.

    sorry.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •