none
Data type mismatch in criteria expression. MS Access VS2014 Profesional RRS feed

  • Pertanyaan

  • Kepada senior yg saya hormati saya mengalami permasalahan dalam Insert into dalam masalah sebagai berikut judul di atas

    Imports System.Data
    Imports System.Data.OleDb
    Public Class KendaraanMasuk

        Dim RD As Object
        Dim CMD As OleDbCommand
        Dim jenisken As String
        Dim cucian As String

        Sub Bersihkan()
            noken.Text = ""
            MerkKen.Text = ""
            RB1.Checked = False
            RB2.Checked = False
            RB3.Checked = False
            RB4.Checked = False
            CB1.Checked = False
            CB2.Checked = False
            CB3.Checked = False
            Total.Text = 0
            noken.Focus()
        End Sub


        Sub NotrankOtomatis()
            CMD = New OleDbCommand("Select * from Tranksaksi_cuci where no_transaksi in (select max(no_transaksi)From Tranksaksi_cuci) order by no_transaksi desc", CONN)
            Dim urutan As String
            Dim hitung As Long
            RD = CMD.ExecuteReader
            RD.Read()
            If Not RD.HasRows Then
                urutan = Format(Now, "yyMMdd") + "0001"
            Else
                If Microsoft.VisualBasic.Left(RD.GetString(0), 6) <> Format(Now, "yyMMdd") Then
                    urutan = Format(Now, "yyMMdd") + "0001"
                Else
                    hitung = RD.GetString(0) + 1
                    urutan = Format(Now, "yyMMdd") + Microsoft.VisualBasic.Right("0000" & hitung, 4)
                End If
            End If
            notrank.Text = urutan
        End Sub


        Sub CariNoplat()
            CMD = New OleDbCommand("select * from Ken_customer where noplat='" & noken.Text & "'", CONN)
            DR = CMD.ExecuteReader
            DR.Read()
        End Sub


        Sub NoplatKetemu()
            On Error Resume Next
            CB1.Checked = False
            CB2.Checked = False
            CB3.Checked = False
            MerkKen.Text = DR.Item("nama_ken")
            If DR.Item("jenis_ken") = "MOBIL KECIL" Then
                RB1.Checked = True
            ElseIf DR.Item("jenis_ken") = "MOBIL SEDANG" Then
                RB2.Checked = True
            ElseIf DR.Item("jenis_ken") = "MOBIL BESAR" Then
                RB3.Checked = True
            ElseIf DR.Item("jenis_ken") = "MOBIL S CLASS" Then
                RB4.Checked = True
            End If


            If DR.Item("histori") = "CUCI BIASA 1" Then
                RB1.Checked = True
            ElseIf DR.Item("histori") = "CUCI BIASA 1 + HIDROLIK" Then
                RB1.Checked = True
                CB1.Checked = True
            ElseIf DR.Item("histori") = "CUCI BIASA 1 + MESIN" Then
                RB1.Checked = True
                CB2.Checked = True
            ElseIf DR.Item("histori") = "CUCI BIASA 1 + HIDROLIK + MESIN" Then
                RB1.Checked = True
                CB1.Checked = True
                CB2.Checked = True

            ElseIf DR.Item("histori") = "CUCI BIASA 2" Then
                RB2.Checked = True
            ElseIf DR.Item("histori") = "CUCI BIASA 2 + HIDROLIK" Then
                RB2.Checked = True
                CB1.Checked = True
            ElseIf DR.Item("histori") = "CUCI BIASA 2 + MESIN" Then
                RB2.Checked = True
                CB2.Checked = True
            ElseIf DR.Item("histori") = "CUCI BIASA 2 + HIDROLIK + MESIN" Then
                RB2.Checked = True
                CB1.Checked = True
                CB2.Checked = True

            ElseIf DR.Item("histori") = "CUCI BIASA 3" Then
                RB3.Checked = True
            ElseIf DR.Item("histori") = "CUCI BIASA 3 + HIDROLIK" Then
                RB3.Checked = True
                CB1.Checked = True
            ElseIf DR.Item("histori") = "CUCI BIASA 3 + MESIN" Then
                RB3.Checked = True
                CB2.Checked = True
            ElseIf DR.Item("histori") = "CUCI BIASA 3 + HIDROLIK + MESIN" Then
                RB3.Checked = True
                CB1.Checked = True
                CB2.Checked = True

            ElseIf DR.Item("histori") = "CUCI BIASA 4" Then
                RB4.Checked = True
            ElseIf DR.Item("histori") = "CUCI BIASA 4 + HIDROLIK" Then
                RB4.Checked = True
                CB1.Checked = True
            ElseIf DR.Item("histori") = "CUCI BIASA 4 + MESIN" Then
                RB4.Checked = True
                CB2.Checked = True
            ElseIf DR.Item("histori") = "CUCI BIASA 4 + HIDROLIK + MESIN" Then
                RB4.Checked = True
                CB1.Checked = True
                CB2.Checked = True
            End If
        End Sub


        Sub NoplatBaru()
            noken.Text = ""
        End Sub
        Sub autocompletCMBplat()
            CMD = New OleDbCommand("select noplat from Ken_customer", CONN)
            DR = CMD.ExecuteReader
            Do While DR.Read
                noken.Items.Add(DR.Item(0)) 'keterangan
            Loop
        End Sub

        Sub autocompletCMBmerk()
            CMD = New OleDbCommand("select nama_ken from Ken_customer", CONN)
            DR = CMD.ExecuteReader
            Do While DR.Read
                MerkKen.Items.Add(DR.Item(0)) 'keterangan
            Loop
        End Sub




        Sub aturDGV1()
            DGV1.DataSource = DS.Tables(0)
            With DGV1.ColumnHeadersDefaultCellStyle
                DGV1.Columns(0).HeaderText = "KODE PAKET"
                DGV1.Columns(1).HeaderText = "PAKET CUCI"
                DGV1.Columns(2).HeaderText = "HARGA"
                DGV1.Columns(2).DefaultCellStyle.Format = "Rp, ###,###,#0"
                DGV1.Columns(0).Width = 100
                DGV1.Columns(1).Width = 250
                DGV1.Columns(2).Width = 250
            End With
        End Sub

        Sub PaketCuci()
            DA = New OleDbDataAdapter("select * from Paket_cuci", CONN)
            DS = New DataSet
            DA.Fill(DS)
            DGV1.DataSource = DS.Tables(0)
            Call aturDGV1()
            DGV1.ReadOnly = True
        End Sub


        Sub cucianmsk()
            On Error Resume Next
            If RB1.Checked = True Then
                Total.Text = Val(hrgsteam.Text)
            ElseIf RB1.Checked = True And CB1.Checked = True Then
                Total.Text = Val(hrgsteam.Text) + Val(lblHidrolik.Text)
            ElseIf RB1.Checked = True And CB2.Checked = True Then
                Total.Text = Val(hrgsteam.Text) + Val(lblCM.Text)
            ElseIf RB1.Checked = True And CB1.Checked = True And CB2.Checked = True Then
                Total.Text = Val(hrgsteam.Text) + Val(lblHidrolik.Text) + Val(lblCM.Text)

            ElseIf RB2.Checked = True Then
                Total.Text = Val(hrgsteam.Text)
            ElseIf RB2.Checked = True And CB1.Checked = True Then
                Total.Text = Val(hrgsteam.Text) + Val(lblHidrolik.Text)
            ElseIf RB2.Checked = True And CB2.Checked = True Then
                Total.Text = Val(hrgsteam.Text) + Val(lblCM.Text)
            ElseIf RB2.Checked = True And CB1.Checked = True And CB2.Checked = True Then
                Total.Text = Val(hrgsteam.Text) + Val(lblHidrolik.Text) + Val(lblCM.Text)


            ElseIf RB3.Checked = True Then
                Total.Text = Val(hrgsteam.Text)
            ElseIf RB3.Checked = True And CB1.Checked = True Then
                Total.Text = Val(hrgsteam.Text) + Val(lblHidrolik.Text)
            ElseIf RB3.Checked = True And CB2.Checked = True Then
                Total.Text = Val(hrgsteam.Text) + Val(lblCM.Text)
            ElseIf RB3.Checked = True And CB1.Checked = True And CB2.Checked = True Then
                Total.Text = Val(hrgsteam.Text) + Val(lblHidrolik.Text) + Val(lblCM.Text)



            ElseIf RB4.Checked = True Then
                Total.Text = Val(hrgsteam.Text)
            ElseIf RB4.Checked = True And CB1.Checked = True Then
                Total.Text = Val(hrgsteam.Text) + Val(lblHidrolik.Text)
            ElseIf RB4.Checked = True And CB2.Checked = True Then
                Total.Text = Val(hrgsteam.Text) + Val(lblCM.Text)
            ElseIf RB4.Checked = True And CB1.Checked = True And CB2.Checked = True Then
                Total.Text = Val(hrgsteam.Text) + Val(lblHidrolik.Text) + Val(lblCM.Text)


            End If
        End Sub

        Sub hargatambah()
            lblHidrolik.Text = "Rp. " & Format(DGV1.Rows(7).Cells(2).Value, "#,#.##")
            lblCM.Text = "Rp. " & Format(DGV1.Rows(8).Cells(2).Value, "#,#.##")
            lblSalonvelg.Text = "Rp. " & Format(DGV1.Rows(9).Cells(2).Value, "#,#.##")
        End Sub



        Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles noken.KeyPress
            If e.KeyChar = Chr(13) Then
                CMD = New OleDbCommand("Select * from Ken_customer where noplat='" & noken.Text & "'", CONN)
                DR = CMD.ExecuteReader
                DR.Read()
                If DR.HasRows Then
                    Call NoplatKetemu()
                    noken.Focus()
                Else
                    MerkKen.Focus()
                End If
            End If
        End Sub

        Private Sub ComboBox1_SelectedValueChanged(sender As Object, e As EventArgs) Handles noken.SelectedValueChanged
            On Error Resume Next
            CMD = New OleDbCommand("select * from Ken_customer where noplat='" & noken.Text & "'", CONN)
            DR = CMD.ExecuteReader
            DR.Read()
            If DR.HasRows Then
                Call NoplatKetemu()
            End If
        End Sub


        Private Sub FormKendaraanMasuk_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Call Koneksi()
            Call autocompletCMBmerk()
            Call autocompletCMBplat()
            Call NotrankOtomatis()
            tanggal.Text = Today
            Call PaketCuci()
            Call hargatambah()
            hrgsteam.Text = "Rp. " & Format(hrgsteam.Text, "0")
            Total.Text = "Rp. " & Format(Total.Text, "0")
        End Sub




        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Call Bersihkan()
        End Sub

        Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            Me.Close()
        End Sub



        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            If noken.Text = "" Then
                MsgBox("NO.Kendaraan Tidak boleh kosong")
                Exit Sub
            End If


            'jika radiobutton dan checkbox disatukan
            If RB1.Checked = True Then
                jenisken = RB1.Text
                cucian = "CUCI BIASA 1"
            ElseIf RB1.Checked = True And CB1.Checked = True Then
                cucian = "CUCI BIASA 1" & " + " & CB1.Text
            ElseIf RB1.Checked = True And CB2.Checked = True Then
                cucian = "CUCI BIASA 1" & " + " & CB2.Text
            ElseIf RB1.Checked = True And CB1.Checked = True And CB2.Checked = True Then
                cucian = "CUCI BIASA 1" & " + " & CB1.Text & " + " & CB2.Text

            ElseIf RB2.Checked = True Then
                jenisken = RB2.Text
                cucian = "CUCI BIASA 2"
            ElseIf RB2.Checked = True And CB1.Checked = True Then
                cucian = "CUCI BIASA 2" & " + " & CB1.Text
            ElseIf RB2.Checked = True And CB2.Checked = True Then
                cucian = "CUCI BIASA 2" & " + " & CB2.Text
            ElseIf RB2.Checked = True And CB1.Checked = True And CB2.Checked = True Then
                cucian = "CUCI BIASA 2" & " + " & CB1.Text & " + " & CB2.Text


            ElseIf RB3.Checked = True Then
                jenisken = RB3.Text
                cucian = "CUCI BIASA 3"
            ElseIf RB3.Checked = True And CB1.Checked = True Then
                cucian = "CUCI BIASA 3" & " + " & CB1.Text
            ElseIf RB3.Checked = True And CB2.Checked = True Then
                cucian = "CUCI BIASA 3" & " + " & CB2.Text
            ElseIf RB3.Checked = True And CB1.Checked = True And CB2.Checked = True Then
                cucian = "CUCI BIASA 3" & " + " & CB1.Text & " + " & CB2.Text


            ElseIf RB4.Checked = True Then
                jenisken = RB4.Text
                cucian = "CUCI BIASA 4"
            ElseIf RB4.Checked = True And CB1.Checked = True Then
                cucian = "CUCI BIASA 4" & " + " & CB1.Text
            ElseIf RB4.Checked = True And CB2.Checked = True Then
                cucian = "CUCI BIASA 4" & " + " & CB2.Text
            ElseIf RB4.Checked = True And CB1.Checked = True And CB2.Checked = True Then
                cucian = "CUCI BIASA 4" & " + " & CB1.Text & " + " & CB2.Text

            End If

            'Simpan Ke tabel Tranksaksi Cuci
            Dim simpanmaster As String = "Insert into Tranksaksi_cuci(no_transaksi,tanggal,noplat,jenis_k,nama_k,pktsteam,status_cuci,total,kode_kasir)values " &
            "('" & notrank.Text & "','" & tanggal.Text & "','" & noken.Text & "','" & jenisken & "','" & MerkKen.Text & "','" & cucian & "','" & status.Text & "','" & Total.Text & "','" & MenuUtama.Panel1.Text & "')"
            CMD = New OleDbCommand(simpanmaster, CONN)
            CMD.ExecuteNonQuery()


            'Simpan Ke tabel Kendaraan Customer
            Try
                Call CariNoplat()
                If Not DR.HasRows Then
                    Dim simpan As String = "insert into Ken_customer(noplat,jenis_ken,nama_ken,histori)values ('" & noken.Text & "','" & jenisken & "','" & MerkKen.Text & "','" & cucian & "')"
                    CMD = New OleDbCommand(simpan, CONN)
                    CMD.ExecuteNonQuery()
                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

            'Simpan ke tabel tbDetailJual
            Dim sqlsimpan As String = "insert into Detail_cuci(no_transaksi,kode_paket,kendaraan,subtotal)values " &
                "('" & notrank.Text & "','" & DGV1.Rows(0).Cells(0).Value & "','" & jenisken & "','" & Total.Text & "')"
            CMD = New OleDbCommand(sqlsimpan, CONN)
            CMD.ExecuteNonQuery()
            Call Bersihkan()
            Call NotrankOtomatis()

        End Sub


        Private Sub RB1_CheckedChanged(sender As Object, e As EventArgs) Handles RB1.CheckedChanged
            DA = New OleDbDataAdapter("select * from Paket_cuci where nama_paket like '%" & RB1.Text & "%'", CONN)
            DS = New DataSet
            DA.Fill(DS)
            DGV1.DataSource = DS.Tables(0)
            DGV1.ReadOnly = True
            If RB1.Checked = True Then
                hrgsteam.Text = "Rp. " & Format(DGV1.Rows(0).Cells(2).Value, "#,#.##")
                Total.Text = hrgsteam.Text
            End If

        End Sub

        Private Sub RB2_CheckedChanged(sender As Object, e As EventArgs) Handles RB2.CheckedChanged
            DA = New OleDbDataAdapter("select * from Paket_cuci where nama_paket like '%" & RB2.Text & "%'", CONN)
            DS = New DataSet
            DA.Fill(DS)
            DGV1.DataSource = DS.Tables(0)
            DGV1.ReadOnly = True
            If RB2.Checked = True Then
                hrgsteam.Text = "Rp. " & Format(DGV1.Rows(0).Cells(2).Value, "#,#.##")
                Total.Text = hrgsteam.Text
            End If

        End Sub

        Private Sub RB3_CheckedChanged(sender As Object, e As EventArgs) Handles RB3.CheckedChanged
            DA = New OleDbDataAdapter("select * from Paket_cuci where nama_paket like '%" & RB3.Text & "%'", CONN)
            DS = New DataSet
            DA.Fill(DS)
            DGV1.DataSource = DS.Tables(0)
            DGV1.ReadOnly = True
            If RB3.Checked = True Then
                hrgsteam.Text = "Rp. " & Format(DGV1.Rows(0).Cells(2).Value, "#,#.##")
            End If

        End Sub

        Private Sub RB4_CheckedChanged(sender As Object, e As EventArgs) Handles RB4.CheckedChanged
            DA = New OleDbDataAdapter("select * from Paket_cuci where nama_paket like '%" & RB4.Text & "%'", CONN)
            DS = New DataSet
            DA.Fill(DS)
            DGV1.DataSource = DS.Tables(0)
            DGV1.ReadOnly = True
            If RB4.Checked = True Then
                hrgsteam.Text = "Rp. " & Format(DGV1.Rows(0).Cells(2).Value, "#,#.##")
            End If

        End Sub

    End Class

    Masalahnya adalah yg saya beri bold pada dan saya garis bawahi itu adalah saat saya ingin insert data ada permasalahan (Data type mismatch in criteria expression.) Mohon kepada senior yg saya hormati bantuan nya terima kasih

    Rabu, 19 Juni 2019 04.32

Semua Balasan

  • 1. data yang string coba kasi nama_text.tostring() misalnya text1.text.tostring()

    2. Data numeric depat tambah cdbl(nama text) misalnya cdbl(textbox1.text)

    3. untuk data tanggal konversi ke convert.todatetime(textbox1.text) 

    Selasa, 16 Juli 2019 11.53