Type mismatch error (different than previous type mismatch?)

R

Roberta

Hello and thanks, in advance, for any thoughts you may be
able to offer on this issue.

I am attempting to update a table based on form input via
combo box. My problem is that, while it appears that
I've designated everything correctly, I'm still getting
an Type Mismatch error when it tries to add the new
record. The table (Key Word Options) is where I would
like the new data to reside in the Keyword field. Both
target and source fields are text.

I pulled this code off the knowledge base and my
modifications worked until the adding the record section.

Private Sub Keyword_NotInList(NewData As String, _
Response As Integer)
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim Msg As String

On Error GoTo Err_Keyword_NotInList

If NewData = "" Then Exit Sub

Msg = "'" & NewData & "' is not in the list." & vbCr
& vbCr
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Please try again."
Else
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("Key Word Options",
dbOpenDynaset)
Rs.AddNew
Rs![Keyword] = NewData
Rs.Update
Response = acDataErrAdded

End If

Exit_Keyword_NotInList:
Exit Sub
Err_Keyword_NotInList:
MsgBox Err.Description
Response = acDataErrContinue

End Sub
 
J

John Vinson

Rs.AddNew
Rs![Keyword] = NewData
Rs.Update
Response = acDataErrAdded

What's the datatype of Keyword? More importantly - *is is a Lookup
field*? If so that's the source of the problem!
 
R

Roberta

Thanks for your help John. The Keyword field (renamed
Options) was not a lookup. It was listed as text. I'm
still getting the error.

The control source field (also named Keyword) was listed
as a lookup in the table. I've changed that to a text
field. I didn't think that piece would matter since it
will write there regardless of the 'copy' of info to the
Keyword Options table.

Keyword Options (table) - 1 field. I just renamed it to
Options so as not to confuse it with the keyword field in
control source. This is the target for the record add.

Again, I appreciate your time.

-----Original Message-----
Rs.AddNew
Rs![Keyword] = NewData
Rs.Update
Response = acDataErrAdded

What's the datatype of Keyword? More importantly - *is is a Lookup
field*? If so that's the source of the problem!


.
 
J

John Vinson

The control source field (also named Keyword) was listed
as a lookup in the table. I've changed that to a text
field. I didn't think that piece would matter since it
will write there regardless of the 'copy' of info to the
Keyword Options table.

If the field was created using the Lookup wizard, it would actually be
a numeric field, an ID linked to the (also wizard-created) Autonumber
ID in the Keyword/Options table. The actual nature and content of the
field are concealed from view by the blankety-blank Lookup misfeature,
so it's hard to spot!

If you look at the table design, what's on the Lookup tab for this
field? It should be textbox. And what's its datatype? And in table
datasheet view, does the field contain key words, or does it contain
numbers?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top