``````If Option1.Value = True Then
a = 3
End If

If Option2.Value = True Then
a = 2
End If

If Option1.Value = True Then
a = 1
End If

If Option4.Value = True Then
b = 3
ElseIf Option5.Value = True Then
b = 2
Else
b = 1
End If

If Option7.Value = True Then
c = 3
ElseIf Option8.Value = True Then
c = 2
Else
c = 1
End If

If Option10.Value = True Then
d = 3
ElseIf Option11.Value = True Then
d = 2
Else
d = 1
End If

If Option13.Value = True Then
e = 3
ElseIf Option14.Value = True Then
e = 2
Else
e = 1
End If

If Option16.Value = True Then
f = 3
ElseIf Option17.Value = True Then
f = 2
Else
f = 1
End If

rs.Open "Insert into section1 VALUES ('" + Label24.Caption + "','" + a + "','" + b + "','" + c + "','" + d + "','" + e + "','" + f + "')", cn, adOpenKeyset, adLockPessimistic``````

please help me to solve my problem, i'm getting this kind of error 'type mismatch' in my insert into.

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by labq5

Ryan, two things.

1 - Have a look at your option button values at the top, you will get an error in the returned value on Option1, because you have given "a" two different values -

``````If Option1.Value = True Then
a = 3
End If

If Option2.Value = True Then
a = 2
End If
If Option1.Value = True Then
a = 1
End If 'You gave a a value of 3 above AND then 1 below. Is this correct?``````

Then to your Insert value, use the following -

``rs.Open "Insert into section1 VALUES ('" & Label24.Caption & "','" & a & "','" & b & "','" & c & "','" & d & "','" & e & "','" & f & "')", cn, adOpenKeyset, adLockPessimistic``

This is to use what you have above. I would have created a string to hold all of the above and use it as follow -

``````Dim strSql As String

strSql = Label24.Caption & a & b & c & d & e & f

rs.Open "Insert into section1 VALUES ('" & strSql & "')", cn, adOpenKeyset, adLockPessimistic``````

Let me know if this solved your problem.

may be your code for insert is not correnct
i usually make this

``````Conn.BeginTrans
MySqL = "INSERT INTO table_name (Field1, Field2, etc) " & _
"Values ('" & String & "','" & String & "','" & etc & "')"
Conn.Execute MySqL
Conn.CommitTrans``````

hope this solve

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.