A
Alp Bekisoglu
It might be an obvious one but... why do I get this error on clicking the
"Command0" button? Any help is much appreciated.
TIA
Alp
Code:
Private Sub Command0_Click()
DAOQuery
End Sub
Function DAOQuery() As Long
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strQry As String, tablo As String, yr As Long
tablo = Me!nm
yr = Me!ygir
On Error GoTo DAOQuery_Error
Set dbs = CurrentDb()
strQry = "SELECT fm As basla, to As son, first As ilk, tax As vergi, next
As sonraki, rate As oran FROM " & tablo & " WHERE [" & tablo & "].from<=" &
yr & " And [" & tablo & "].to>=" & yr
' strQry = "SELECT Count(year) As numRecords FROM " & tablo 'SQL
Set rst = dbs.OpenRecordset(strQry)
Me!Text6 = strQry
With rst
DAOQuery = !vergi + ((yr - !ilk) * !oran)
Me!Text8 = DAOQuery
Me!bas = !basla
Me!son = !son
Me!first = !ilk
Me!tax = !vergi
Me!sonra = !sonraki
Me!voran = !oran
'.Close 'close the DAO recordset
End With
Set rst = Nothing
Set dbs = Nothing
On Error GoTo 0
Exit Function
DAOQuery_Error:
MsgBox "Error " & Err.Number & " (" & Err.description & ")", vbCritical
End Function
"Command0" button? Any help is much appreciated.
TIA
Alp
Code:
Private Sub Command0_Click()
DAOQuery
End Sub
Function DAOQuery() As Long
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strQry As String, tablo As String, yr As Long
tablo = Me!nm
yr = Me!ygir
On Error GoTo DAOQuery_Error
Set dbs = CurrentDb()
strQry = "SELECT fm As basla, to As son, first As ilk, tax As vergi, next
As sonraki, rate As oran FROM " & tablo & " WHERE [" & tablo & "].from<=" &
yr & " And [" & tablo & "].to>=" & yr
' strQry = "SELECT Count(year) As numRecords FROM " & tablo 'SQL
Set rst = dbs.OpenRecordset(strQry)
Me!Text6 = strQry
With rst
DAOQuery = !vergi + ((yr - !ilk) * !oran)
Me!Text8 = DAOQuery
Me!bas = !basla
Me!son = !son
Me!first = !ilk
Me!tax = !vergi
Me!sonra = !sonraki
Me!voran = !oran
'.Close 'close the DAO recordset
End With
Set rst = Nothing
Set dbs = Nothing
On Error GoTo 0
Exit Function
DAOQuery_Error:
MsgBox "Error " & Err.Number & " (" & Err.description & ")", vbCritical
End Function