Question : I have an Access 2003 table-want field to autofill

I have an Access 20003 table. In a form there is a field for "City"
When adding a new record if that city has been previously added - can it automatically come up when I start typing.

Answer : I have an Access 2003 table-want field to autofill

Sure!
:)

There are many, here is one:
http://support.microsoft.com/kb/197526

There is also a simpler example of this technique in almost every MS sample database.
Here is one to add a new category:
Private Sub CategoryID_NotInList(NewData As String, Response As Integer)
    MsgBox "Double-click this field to add an entry to the list."
    Response = acDataErrContinue
End Sub

Private Sub CategoryID_DblClick(Cancel As Integer)
    Dim lngCategoryID As Long

    If IsNull(Me![CategoryID]) Then
        Me![CategoryID].Text = ""
    Else
        lngCategoryID = Me![CategoryID]
        Me![CategoryID] = Null
    End If
    DoCmd.OpenForm "Categories", , , , , acDialog, "GotoNew"
    Me![CategoryID].Requery
    If lngCategoryID <> 0 Then Me![CategoryID] = lngCategoryID
End Sub
(But here you must make your dreaded "New Form")
:O
There are many more, you can google: Combobox Add Record NotInList

However!, the danger is still there:
You might not want *Any* user to do this.
This *still* does nothing to stop 3 people from entering 3 different spellings for the same name!
(In fact, it make it easier!)
Just make sure only people you trust are entering new Cities.

It does not have to be much, just a simple password might suffice.
So in the code above, it would look something like this:

Private Sub CategoryID_NotInList(NewData As String, Response As Integer)
    MsgBox "Double-click this field to add an entry to the list."
    Response = acDataErrContinue
End Sub

Private Sub CategoryID_DblClick(Cancel As Integer)
Dim strAttPword as String
strAttPword =InputBox("Enter Password to add a City:")
    If strAttPword <>"YourPassword" Then
        Msgbox "You are not authorized to add a City.", vbInformation
        Exit Sub
    End If
'The NotInListCode goes here
Dim lngCategoryID As Long

    If IsNull(Me![CategoryID]) Then
        Me![CategoryID].Text = ""
    Else
        lngCategoryID = Me![CategoryID]
        Me![CategoryID] = Null
    End If
    DoCmd.OpenForm "Categories", , , , , acDialog, "GotoNew"
    Me![CategoryID].Requery
    If lngCategoryID <> 0 Then Me![CategoryID] = lngCategoryID
End Sub

Hope this all helps set you on the right track!
:)

PS.
Do not forget that Pete and Mike *Did* answer your original Question.
So technically, the points should go to them.

You can take anything I posted as a Holiday Present.
:)

JeffCoachman
Random Solutions  
 
programming4us programming4us