Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Error 13 type mismatch

Geek News

Error 13 type mismatch
Walter 12/24/2008 2:13:00 PM
I have the following code and I keep getting a type mismatch error. I've
tried every possiblity that I can think of to no avail. I haven't been able
to find anything that seems to relate to my situation.

Dim strOldPosition As String
Dim strNewPosition As String
Dim intOldPosition As Integer
Dim intNewPosition As Integer
Dim intOldTire As Integer
Dim intNewTire As Integer

strOldPosition = Me.ActiveControl.Caption
strNewPosition = Nz(Forms!frmUpdateTireLocation!cboNewPosition, 0)
intOldPosition = _
"Select tblTirePosition.TirePositionID " & _
"From tblTirePosition " & _
"Where (((tblTirePosition.TirePosition) = """ & strOldPosition &
"""" & "));"

The code breaks at the query defining intOldPosition.
tblTirePosition.TirePosition is a text field. What am I missing?

--
Thanks for your help!
Walter
Re: Error 13 type mismatch
"Linq Adams via AccessMonster.com" <u28780[ at ]uwe> 12/24/2008 2:54:42 PM
Your type mismatch error is coming from your assigning an Integer variable

intOldPosition

a String value

"Select tblTirePosition.TirePositionID " & _
"From tblTirePosition " & _
"Where (((tblTirePosition.TirePosition) = """ & strOldPosition &
"""" & "));"


Access isn't going to automatically run the SQL statement when you've given
it no instructions to do so! Access evaluates

"Select tblTirePosition.TirePositionID " & _
"From tblTirePosition " & _
"Where (((tblTirePosition.TirePosition) = """ & strOldPosition &
"""" & "));"

as just what it is; a String.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200812/1

Re: Error 13 type mismatch
Tom van Stiphout <tom7744.no.spam[ at ]cox.net> 12/24/2008 3:02:57 PM
On Wed, 24 Dec 2008 06:13:00 -0800, Walter
<Walter[ at ]discussions.microsoft.com> wrote:

In the last line you essentially write:
i = "abc"
If the variable i is an integer, its value can only be a whole 16-bit
number, not a string.
It appears that what you want is to do a database lookup for some
specific integer value, and assign that to your integer variable:
i = <some_database_lookup>
Fortunately there is a solution for that: the DLookup function. Look
it up in the help file.

-Tom.
Microsoft Access MVP



[Quoted Text]
>I have the following code and I keep getting a type mismatch error. I've
>tried every possiblity that I can think of to no avail. I haven't been able
>to find anything that seems to relate to my situation.
>
>Dim strOldPosition As String
> Dim strNewPosition As String
> Dim intOldPosition As Integer
> Dim intNewPosition As Integer
> Dim intOldTire As Integer
> Dim intNewTire As Integer
>
> strOldPosition = Me.ActiveControl.Caption
> strNewPosition = Nz(Forms!frmUpdateTireLocation!cboNewPosition, 0)
> intOldPosition = _
> "Select tblTirePosition.TirePositionID " & _
> "From tblTirePosition " & _
> "Where (((tblTirePosition.TirePosition) = """ & strOldPosition &
>"""" & "));"
>
>The code breaks at the query defining intOldPosition.
>tblTirePosition.TirePosition is a text field. What am I missing?
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net