简体   繁体   English

条件表达式中的数据类型不匹配 SQL Select In Access

[英]Data type mismatch in criteria expression SQL Select In Access

Dim db As Database
Dim rrs As Recordset
Dim strselect As String
Set db = CurrentDb
strselect = "SELECT [Stok Pembelian] FROM t_databarang WHERE [ID Barang]= '" & Me.Text7 & "'"
Set rrs = db.OpenRecordset(strselect)
Me.Label1.Caption = rrs![Stok Pembelian]

I have a project from my school.我有一个学校的项目。 I'm beginers and i'm so confused about my Access.我是初学者,我对我的访问感到很困惑。 I think that code it's correct, but there's an error "Data type mismatch in criteria expression."我认为该代码是正确的,但有一个错误“条件表达式中的数据类型不匹配”。 I already search much articles about how tow to fix it but not found.我已经搜索了很多关于如何解决它的文章,但没有找到。 Please, help me.请帮我。

Try to convert the textbox value into a double or int...尝试将文本框值转换为 double 或 int ...

Dim Text7a as Double

Text7a = CLng(Me.Text7) 'Beware of rounding with Long Integers

Now use the alias Text7a for:现在将别名Text7a用于:

strselect = "SELECT [Stok Pembelian] FROM t_databarang WHERE [ID Barang]= '" & Me.Text7a & "'"

您的 id 很可能是一个数字,因此没有引号:

strselect = "SELECT [Stok Pembelian] FROM t_databarang WHERE [ID Barang]= " & Me!Text7.Value & ""

Check data types!检查数据类型!
Like "Long Text do not match Number data type."比如“长文本与数字数据类型不匹配”。 Do it both them same data type on your database design在您的数据库设计中使用相同的数据类型

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM