Full Version: Run-time Error 13 Type Mismatch
UtterAccess Forums > Microsoft® Access > Access Forms
simsima
Hi All,

Private Sub cbovoltk_AfterUpdate()
Dim cvoltkind As Integer
cvoltkind = " select * from voltKind where ([voltkind]= '" & Me.cbovoltk & "')"
Me.voltKind_sub.Form.RecordSource = cvoltkind
Me.voltKind_sub.Form.Requery
End Sub

i have these code but i get run-time error 13 type mismatch, what is wrong please help

Regards
azolder
Dim cvoltkind As Integer String
simsima
Hi sir,

the textbox is number not string.
Doug Steele
But what's the data type of voltkind? You could be storing a numeric value in a text field, and that'll cause your error.
simsima
yes sir it's numeric value in a text field
azolder
QUOTE
cvoltkind = " select * from voltKind where ([voltkind]= '" & Me.cbovoltk & "')"

You're assigning a string to the variable, that's giving you the Run-Time Error. And a string is required for the Record Source. The control, Me.cbovoltk, is just a parameter in your expression.

You also shouldn't have a variable name the same as a control name, it confuses the issue. It looks like you're assigning a value to the control. Suggest you try the following.
CODE
Private Sub cbovoltk_AfterUpdate()
   Dim strCvoltkind As String
   strCvoltkind = " select * from voltKind where ([voltkind]= " & Me.cbovoltk & ")" 'single quote removed, assuming voltkind is a number
   Me.voltKind_sub.Form.RecordSource = strCvoltkind
   Me.voltKind_sub.Form.Requery
End Sub
BitBangerUSA
yes - line 2 of your code sets an Integer variable.
then you immediately (Line 3) set that variable to what is clearly a string...
simsima
thank you sir azolder
thank you All for your help.

it's woooooooork
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.