Populating a Combo Box Issue...Again

Judy

Registered User.
Local time
Today, 08:10
Joined
Sep 26, 2000
Messages
34
On June 24 I posted a request and Colin Essex replied to my post by suggesting a way to add an entry to a combo box if not already in the source table. I really like the simplicity of this method, however, I'm getting a run time error that I can't figure out how to fix. Here is my code:

Private Sub ClientCity_NotInList(NewData As String, Response As Integer)

Dim rst As Recordset
Dim strTableName

If MsgBox("Entry not in list, would you like to add it now?", vbOKCancel, "Add City") = vbOK Then
Set rst = CurrentDb.OpenRecordset("tblCities")

rst.AddNew
rst!City = NewData
rst.Update
Set rst = Nothing

Response = acDataErrAdded
Else
Response = acDataErrContinue
ClientCity.Undo
End If
End Sub

The error is run time error '13': Type mismatch (which I know has to do with the data type), but when debugging the code, on the line rst!City = New Data, I get the following message:

rst!City = <Object variable or With block variable not set>.

The table consists of an AutoNumber primary key (CityID) and a text field (City). Can anyone tell me what I'm not seeing??



Thanks!!

Judy
 
Hi Judy

In order to narrow down the problem. May I suggest you re-create the combo box but with only one field (the city text field)

I am unable to recreate your problem apart from when I try to enter text into a number field. But I understand you have checked both fields.

If you like I can have a look at it for you if you want to zip it and email it to me.

Col
 

Users who are viewing this thread

Back
Top Bottom