"Predictive Text" (1 Viewer)

Hellfire

Registered User.
Local time
Today, 11:32
Joined
Jul 23, 2002
Messages
57
Hi, I am new to this discussion so please be kind to me!

I have a VERY basic database that I have been constructing myself. I have had no training, so it is very simple at the moment. I use it to keep track of all the parcels delivered to my office.

In my table/form, I have a box to enter the addressee's name in. I would like this to pick up the names when you start typing them. I am currently using a Combo-box, but with new members of staff, and short-term personnel, it is a very long-winded way of adding new names to the Combo-box.

Can anyone help me? Any suggestions?
 

jatfill

Registered User.
Local time
Today, 06:32
Joined
Jun 4, 2001
Messages
150
I'm assuming then that you are building a table of first names, last names where the combo box their data. This is, to my knowledge, the best way of doing things that you want 'autofilled.'

Here's some code I picked up not too long ago from Microsoft's Web Site & modified to "transparently" add new values to a name table (in my case I was building a list of cities, but this would work for anything really.

Put this behind the "AfterUpdate" property of your combo box & change the table/field names to reflect your information...

Code:
If DCount("[name]", "tblName", "[name] = '" & Me.comboboxname & "'") = 0 Then
    Dim db As DAO.Database
Dim rs As DAO.Recordset

        Set db = CurrentDb
        Set rs = db.OpenRecordset("tblName", dbOpenDynaset)
        On Error Resume Next
        rs.AddNew
            rs!name = Me.comboboxname
        rs.Update
        
        If Err Then
            MsgBox "An error occurred. Please try again."
            Response = acDataErrContinue
        Else
            Response = acDataErrAdded
        
        End If
Set db = Nothing
rs.Close
Set rs = Nothing

End If
 

Users who are viewing this thread

Top Bottom