[RESOLVED] Problem with Code
Hello,
The following piece of code I am having an error in. I divided it to two parts to simplify it.
VB Code:
Dim sConnString As String
Dim rsTempRecordSet As New ADODB.Recordset
Dim cnTeamCMI As New ADODB.Connection
Dim sSQl As String
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\ÅÓáÇã\ÓØÍ ÇáãßÊÈ\ÈÑäÇãÌ ÇáÍÖæÑ æ ÇáÇäÕÑÇÝ\database.mdb;Jet OLEDB:Engine Type=5;"
With cnTeamCMI
.ConnectionString = sConnString
.ConnectionTimeout = 0
.CursorLocation = adUseClient
.Open strConnString
End With
sSQl = "SELECT [ÑÕíÏ ÇáÅÌÇÒÇÊ] FROM [ÇáÅÏÇÑí] WHERE [ÇÓã ÇáÚÇãá] = '" & lstMngment.List(lstMngment.ListIndex) & "'"
rsTempRecordSet.Open sSQl, cnTeamCMI, adOpenStatic, adLockReadOnly
With rsTempRecordSet
If .Fields("ÑÕíÏ ÇáÅÌÇÒÇÊ") >= 1 Then
cmdMGTHoliday.Enabled = True
Else
cmdMGTHoliday.Enabled = False
End If
End With
rsTempRecordSet.Close
Set rsTempRecordSet = Nothing
Set cnTeamCMI = Nothing
This part is fine. But I get the error in his part of code:
VB Code:
With cnTeamCMI
.ConnectionString = sConnString
.ConnectionTimeout = 0
.CursorLocation = adUseClient
.Open strConnString
End With
sSQl = "SELECT [ÍÖæÑ] FROM [ÊæÞíÊÇÊ ÇáÅÏÇÑí] WHERE [ÇÓã ÇáÚÇãá] = '" & lstMngment.List(lstMngment.ListIndex) & "' AND [ÊÇÑíÎ ÇáÏÎæá] = #" & Format(Now, "dd/mm/yy") & "#"
rsTempRecordSet.Open sSQl, cnTeamCMI, adOpenStatic, adLockReadOnly
With rsTempRecordSet
If .Fields("ÍÖæÑ") = "ÅÌÇÒÉ" Then
cmdMGTHoliday.Enabled = False
Else
cmdMGTHoliday.Enabled = True
End If
End With
rsTempRecordSet.Close
End Sub
It highlights this line: " If .Fields("ÍÖæÑ") = "ÅÌÇÒÉ" Then" with an error message telling me that either BOF or EIF is True, or the current record has been deleted, the process needs a current record. (The error message is in Arabic I tried to translate as accurate as I could). Any suggestions on how to solve this problem?
Thanx in advance :) !
Re: [RESOLVED] Problem with Code
Usually I do it this way...
VB Code:
If DateValue(.Fields("ÊÇÑíÎ ÇáÏÎæá")) = DateValue(Date) Then