list with inputfield

Yes I did before, but it wouldn't work, so I deleted it again :)
Erm... so that means it's working now?

If it's not, did you see JANR's sample db in post #18. I've not opened it but I trust JANR created what you're after.
 
Erm... so that means it's working now?

If it's not, did you see JANR's sample db in post #18. I've not opened it but I trust JANR created what you're after.

No it's not working :)
I would like to have the database example but I can't open it:
unknown database format
I'm using Access 2007 dough.
 
So going back to an old suggestion:
Code:
Private Sub CustomerNotInList(NewData As String, Response As Integer)
    If Msgbox("Add new entry?", vbYesNo, "new entry") = vbYes then
        Currentdb.execute "Insert Into Customer (Customer) Values ('" & NewData & "');"
        Response = acdataerradded
[COLOR=Red]        me.customernotinlist.requery[/COLOR]
    End if
End Sub
After the code runs, look in the combo box and you should find that entry.
 
I tried the code, but again it won't work :S
He doesn't pop up the MsgBox and doesn't add the new value to the table.
 
I'm beging to think that you have som sort of corruption going on, lets try this experiment.
1. Create a New database shell
2. Create a table and call it "Customer"
3. In this table create 2 fields
- CustID ---> Autonumber
- Customer----> text
4. Download the textfile attached to this post and save it ex. d:\
5. Create a module and in this module paste in this Function:

Code:
Function GetForm(frmtxt As String)
Application.LoadFromText acForm, "MyForm", frmtxt
End Function

6. Run the function from the immediate window, type in this and hit enter.

?getform("d:\frm1.txt")

7. Open MyForm and test it
If this works then look at the properies and setup and recreate it in your form, if it dosen't then there might be problems with you access installation.

JR
 

Attachments

Do you mind sharing what the fix was?

JR
 
well, The option 'list only' was set on 'No'.
I put it to 'Yes' and it worked ^^
 
ahh Limit To list, I had a naging feeling that it was something simple but easy to overlook.

A Lesson learned. :-)

JR
 
Here's the code I used ^^

Code:
[CODE]Private Sub cboJobTitle_NotInList(NewData As String,  
   Response As Integer)
    On Error GoTo cboJobTitle_NotInList_Err
    Dim intAnswer As Integer
    Dim strSQL As String
    intAnswer = MsgBox("The job title " & Chr(34) & NewData & _
        Chr(34) & " is not currently listed." & vbCrLf & _
        "Would you like to add it to the list now?" _
        , vbQuestion + vbYesNo, "Acme Oil and Gas")
    If intAnswer = vbYes Then
        strSQL = "INSERT INTO tblJobTitles([JobTitle]) " & _
                 "VALUES ('" & NewData & "');"
        DoCmd.SetWarnings False
        DoCmd.RunSQL strSQL
        DoCmd.SetWarnings True
        MsgBox "The new job title has been added to the list." _
            , vbInformation, "Acme Oil and Gas"
        Response = acDataErrAdded
    Else
        MsgBox "Please choose a job title from the list." _
            , vbInformation, "Acme Oil and Gas"
        Response = acDataErrContinue
    End If
cboJobTitle_NotInList_Exit:
    Exit Sub
cboJobTitle_NotInList_Err:
    MsgBox Err.Description, vbCritical, "Error"
    Resume cboJobTitle_NotInList_Exit
End Sub
[/CODE]

This threat can be closed =D
 

Users who are viewing this thread

Back
Top Bottom