Rabu, 22 Mei 2013

Re: Format Tgl Acces-MySql-MsQl / dh [belajar-access] Tombol Cari

 

aslm pak
 
masih Tanya juga ni masih eroh juga imput tanggal sql pada vba nya mohon pencerahan dimana salahnya
 
Private Sub CmdSimpan_Click()
Call koneksi
Dim sql As String
      sql = "insert into Sekolah (sek_NSS,Sek_UNIK,Sek_Tis_Kode,Sek_Nama,Sek_Status,Sek_NamaPimpinan," _
                        & " Sek_YysnNama,Sek_YysnAlamat,Sek_YysnKelompok,Sek_Akreditasi," _
                        & " Sek_Klp_ID,Sek_Alamat,Sek_Desa,Sek_Geo_ID,Sek_KodePOS,Sek_Kab_ID,Sek_Kec,Sek_NoTelp," _
                        & "Sek_Fax,Sek_email,Sek_website) values ('" & TextNPSN & "','" & TextNSS & _
                        "','" & cbmTingkat & _
                        "','" & TextSekolah & _
                        "','" & cmbStatus & _
                        "','" & TextPimpinan & _
                        "','" & TextNamaYayasan & _
                        "','" & TextAlamatYayasan & _
                        "','" & cmbKelompokYayasan & _
                        "','" & cmbAkreditasi & _
                        "','" & cmbKelompokSMK & _
                        "','" & TextAlamat & _
                        "','" & TextKelurahan & _
                        "','" & cmbLokasi & _
                        "','" & TextKodePos & _
                        "','" & cmbKabupaten & _
                        "','" & cmbKecamatan & _
                        "','" & TextTelepon & _
                        "','" & TextFax & _
                        "','" & TextEmail & _
                        "','" & TextWebsite & _
                        "','" & TglFalid & _
                        "','" & Format(Date, "yyyy/mm/dd") & "')"
    'sql = "insert into sekolah(Sek_LastUpdate) values ('" & Format(Date, "yyyy/mm/dd") & "')"
      conn.Execute sql
    Call bersih
    Call Blank
End Sub
 

From: hari yanto <har_i20002000@yahoo.com>
To: belajar-access@yahoogroups.com
Sent: Wednesday, May 22, 2013 2:12 AM
Subject: Re: Format Tgl Acces-MySql-MsQl / dh [belajar-access] Tombol Cari
 
Wa'alaikum salam Wr Wb..
 
Kalau database pakai MySql, yang digunakan bukan yang untuk Ms Acces. Tapi yang MySql:
 
Format(TGL, "YYYY-MM-DD")
Jadi sql paling akhir diubah dari semula:
 
 "','" & tglValid(Date, for_date) & "')"
menjadi:
 
 "','" & Format(tglValid, "YYYY-MM-DD") & "')"
Semoga bisa membantu dan memberi semangat.
 
Hariyanto (Surabaya)
 
--- On Wed, 22/5/13, Muzakkir Nasruddin <zakirnas@ymail.com> wrote:

From: Muzakkir Nasruddin <zakirnas@ymail.com>
Subject: Re: Format Tgl Acces-MySql-MsQl / dh [belajar-access] Tombol Cari
To: "belajar-access@yahoogroups.com" <belajar-access@yahoogroups.com>
Date: Wednesday, 22 May, 2013, 10:43 AM

 
aslm pak har
 
saya uda cabo gunakam fungsi tangga  masih tapi error sya menggunakan MySQL mohon pencerahan
 
Function for_date()
    If CInt(Left(CStr(DateSerial(2012, 1, 2)), 2)) = 2 Then
        for_date = "yyyy/mm/dd"
    Else
        for_date = "mm/dd/yyyy"
    End If
End Function
 
Private Sub CmdSimpan_Click()
Call koneksi
Dim sql As String
      sql = "insert into Sekolah (sek_NSS,Sek_UNIK,Sek_Tis_Kode,Sek_Nama,Sek_Status,Sek_NamaPimpinan," _
                        & " Sek_YysnNama,Sek_YysnAlamat,Sek_YysnKelompok,Sek_Akreditasi," _
                        & " Sek_Klp_ID,Sek_Alamat,Sek_Desa,Sek_Geo_ID,Sek_KodePOS,Sek_Kab_ID,Sek_Kec,Sek_NoTelp," _
                        & "Sek_Fax,Sek_email,Sek_website,Sek_LastUpdate) values ('" & TextNPSN & "','" & TextNSS & _
                        "','" & cbmTingkat & _
                        "','" & TextSekolah & _
                        "','" & cmbStatus & _
                        "','" & TextPimpinan & _
                        "','" & TextNamaYayasan & _
                        "','" & TextAlamatYayasan & _
                        "','" & cmbKelompokYayasan & _
                        "','" & cmbAkreditasi & _
                        "','" & cmbKelompokSMK & _
                        "','" & TextAlamat & _
                        "','" & TextKelurahan & _
                        "','" & cmbLokasi & _
                        "','" & TextKodePos & _
                        "','" & cmbKabupaten & _
                        "','" & cmbKecamatan & _
                        "','" & TextTelepon & _
                        "','" & TextFax & _
                        "','" & TextEmail & _
                        "','" & TextWebsite & _
                        "','" & tglValid(Date, for_date) & "')"
      conn.Execute sql
    Call bersih
    Call Blank
End Sub
 
From: hari yanto <har_i20002000@yahoo.com>
To: belajar-access@yahoogroups.com
Sent: Tuesday, May 21, 2013 4:34 PM
Subject: Format Tgl Acces-MySql-MsQl / dh [belajar-access] Tombol Cari
 


--- On Wed, 22/5/13, Muzakkir Nasruddin <zakirnas@ymail.com> wrote:

From: Muzakkir Nasruddin <zakirnas@ymail.com>
Subject: Re: Bls: [belajar-access] Tombol Cari
To: "belajar-access@yahoogroups.com" <belajar-access@yahoogroups.com>
Date: Wednesday, 22 May, 2013, 12:33 AM

 
Wa'alaikumsalam Wr Wb...
 
Bismillahirrohmanirrohim...
 
Memang ada perbedaan format tanggal antara Ms Acees-MySql-MsQl. Terutama bila kita eksekusi via VBA. Untuk Database MySql dan MsQl, format-nya harus diubah (mengikuti format database):
 
Format(TGL, "YYYY-MM-DD")
 
Sedangkan bila Databasenya Ms Acces, formatnya (entah dari mana saya temukan) dibuat sendiri. Lalu diletakkan pada format date. Ini scriptnya:
 
Function for_date()
    If CInt(Left(CStr(DateSerial(2012, 1, 2)), 2)) = 2 Then         for_date = "dd/mm/yyyy"     Else         for_date = "mm/dd/yyyy"     End If
End Function
 
Contoh penggunaan di sql:
 
db.Execute "insert into TblPelanggan (IDRecord,TglAktif,KodePel)" _         & " values (" & idrec & ",#" & Format(Date, for_date) & "#," & ubah(idpel) & ")"
 
Semoga bisa membantu dan memberi semangat.
 
 
Hariyanto (Surabaya)
aslm komunitas accesss
 
saya mengemui kendala dalam input data tanggal dengan menggunakan sql mohon pencerahan dalam memasuknan tanggal Pendirian
 
mis
 
Private Sub CmdSimpan_Click()
Call koneksi Dim sql As String       sql = "insert into Sekolah (sek_NSS,Sek_UNIK,Sek_Tis_Kode,Sek_Nama,Sek_Status,Sek_NamaPimpinan," _                         & " Sek_Tgl_Pedirian) values ('" & TextNPSN & "','" & TextNSS & _                         "','" & cbmTingkat & _                         "','" & TextSekolah & _                         "','" & cmbStatus & _                         "','" & TextPimpinan & _                         "','" & TextTgl_Pedirian& "')"
 conn.Execute sql     Call bersih     Call Blank End Sub
 
 
zakirnas

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (16)
Recent Activity:
SPAM IS PROHIBITED
.

__,_._,___

Tidak ada komentar:

Posting Komentar