第一次發佈......我敢肯定這可能是簡單的東西,所以我提前道歉。這實際上是我第一次使用VBA工作,並且遇到了問題。儘管我嘗試了一些東西,但我仍然搜索並嘗試了多種東西,但仍然是同樣的問題訪問數據庫運行時錯誤13類型不匹配
我搬到數據庫到另一臺機器,現在我得到運行時錯誤13.調試器說,這是在第28行:
Me!odf = CVDate("01.01.1800")
它當你點擊按鈕,爲特定的搜索數據庫打開新窗口的由用戶設置的標準。
下面是代碼:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "Form_Pregledt"
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Compare Database
Private Sub Angioloski_Click()
Forms!PREGLEDT!Pregledf.Form!Idpregleda.RowSource = "SELECT [Qpregledt].[Idpregleda], [Qpregledt].[Datum], [Qpregledt].[Prezime i ime], [Qpregledt].[Godina rodjenja], [Qpregledt].[Adresa], [Qpregledt].[Telefon], [Qpregledt].[Faks], [Qpregledt].[e-mail] FROM [Qpregledt] WHERE [VRSTA PREGLEDA]=FORMS!PREGLEDT!VRSTA AND [ANGIOLOSKI]=FORMS!PREGLEDT!ANGIOLOSKI and datum>=forms!pregledt!odf and datum<=forms!pregledt!dof "
Forms!PREGLEDT!Pregledf.Form!Idpregleda.Requery
Forms!PREGLEDT!Pregledf.Form!ukupno.Caption = "Ukupno: " & Forms!PREGLEDT!Pregledf.Form!Idpregleda.ListCount
Me.Refresh
End Sub
Private Sub do_AfterUpdate()
If IsNull(Me!od) = True Then
Me!odf = CVDate("01.01.1800")
Else
Me!odf = Me!od
End If
If IsNull(Me!do) = True Then
Me!dof = CVDate("01.01.2800")
Else
Me!dof = Me!do
End If
Forms!PREGLEDT!Pregledf.Form!Idpregleda.Requery
Forms!PREGLEDT!Pregledf.Form!ukupno.Caption = "Ukupno: " & Forms!PREGLEDT!Pregledf.Form!Idpregleda.ListCount
Me.Refresh
End Sub
Private Sub Form_Load()
Forms!PREGLEDT!Pregledf.Form!ukupno.Caption = "Ukupno: " & Forms!PREGLEDT!Pregledf.Form!Idpregleda.ListCount
Me!odf = CVDate("01.01.1800")
Me!dof = CVDate("01.01.2800")
Forms!PREGLEDT!Pregledf.Form!Idpregleda.Requery
Forms!PREGLEDT!Pregledf.Form!ukupno.Caption = "Ukupno: " & Forms!PREGLEDT!Pregledf.Form!Idpregleda.ListCount
Me.Refresh
End Sub
Private Sub od_AfterUpdate()
If IsNull(Me!od) = True Then
Me!odf = CVDate("01.01.1800")
Else
Me!odf = Me!od
End If
If IsNull(Me!do) = True Then
Me!dof = CVDate("01.01.2800")
Else
Me!dof = Me!do
End If
Forms!PREGLEDT!Pregledf.Form!Idpregleda.Requery
Forms!PREGLEDT!Pregledf.Form!ukupno.Caption = "Ukupno: " & Forms!PREGLEDT!Pregledf.Form!Idpregleda.ListCount
Me.Refresh
End Sub
Private Sub vrsta_Click()
If Me!vrsta = 1 Then
Me!Angioloski.Enabled = True
Else
Me!Angioloski.Enabled = False
Me!Angioloski = Null
End If
If IsNull(Me!vrsta) = False Then
If IsNull(Me!Angioloski) = True Then
Forms!PREGLEDT!Pregledf.Form!Idpregleda.RowSource = "SELECT [Qpregledt].[Idpregleda], [Qpregledt].[Datum], [Qpregledt].[Prezime i ime], [Qpregledt].[Godina rodjenja], [Qpregledt].[Adresa], [Qpregledt].[Telefon], [Qpregledt].[Faks], [Qpregledt].[e-mail] FROM [Qpregledt] WHERE [VRSTA PREGLEDA]=FORMS!PREGLEDT!VRSTA and datum>=forms!pregledt!odf and datum<=forms!pregledt!dof "
Else
Forms!PREGLEDT!Pregledf.Form!Idpregleda.RowSource = "SELECT [Qpregledt].[Idpregleda], [Qpregledt].[Datum], [Qpregledt].[Prezime i ime], [Qpregledt].[Godina rodjenja], [Qpregledt].[Adresa], [Qpregledt].[Telefon], [Qpregledt].[Faks], [Qpregledt].[e-mail] FROM [Qpregledt] WHERE [VRSTA PREGLEDA]=FORMS!PREGLEDT!VRSTA AND [ANGIOLOSKI]=FORMS!PREGLEDT!ANGIOLOSKI and datum>=forms!pregledt!odf and datum<=forms!pregledt!dof"
End If
End If
Forms!PREGLEDT!Pregledf.Form!Idpregleda.Requery
Forms!PREGLEDT!Pregledf.Form!ukupno.Caption = "Ukupno: " & Forms!PREGLEDT!Pregledf.Form!Idpregleda.ListCount
Me.Refresh
End Sub
Private Sub izlaz_Click()
'On Error GoTo Err_izlaz_Click
On Error Resume Next
DoCmd.Close
Exit_izlaz_Click:
Exit Sub
Err_izlaz_Click:
MsgBox Err.Description
Resume Exit_izlaz_Click
End Sub
嘗試分離日期以'/'而不是'。 ':) – Tim 2014-09-24 04:05:49
謝謝!這解決了我的問題:) – 2014-09-24 08:07:49