Hello,
The following piece of code I am having an error in. I divided it to two parts to simplify it.
VB Code:
  1. Dim sConnString As String
  2.     Dim rsTempRecordSet As New ADODB.Recordset
  3.     Dim cnTeamCMI As New ADODB.Connection
  4.     Dim sSQl As String
  5.     strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\ÅÓáÇã\ÓØÍ ÇáãßÊÈ\ÈÑäÇãÌ ÇáÍÖæÑ æ ÇáÇäÕÑÇÝ\database.mdb;Jet OLEDB:Engine Type=5;"
  6.     With cnTeamCMI
  7.         .ConnectionString = sConnString
  8.         .ConnectionTimeout = 0
  9.         .CursorLocation = adUseClient
  10.         .Open strConnString
  11.     End With
  12.         sSQl = "SELECT [ÑÕíÏ ÇáÅÌÇÒÇÊ] FROM [ÇáÅÏÇÑí] WHERE [ÇÓã ÇáÚÇãá] = '" & lstMngment.List(lstMngment.ListIndex) & "'"
  13.         rsTempRecordSet.Open sSQl, cnTeamCMI, adOpenStatic, adLockReadOnly
  14.     With rsTempRecordSet
  15.  
  16.         If .Fields("ÑÕíÏ ÇáÅÌÇÒÇÊ") >= 1 Then
  17.         cmdMGTHoliday.Enabled = True
  18.         Else
  19.         cmdMGTHoliday.Enabled = False
  20.         End If
  21.     End With
  22. rsTempRecordSet.Close
  23. Set rsTempRecordSet = Nothing
  24. Set cnTeamCMI = Nothing
This part is fine. But I get the error in his part of code:
VB Code:
  1. With cnTeamCMI
  2.         .ConnectionString = sConnString
  3.         .ConnectionTimeout = 0
  4.         .CursorLocation = adUseClient
  5.         .Open strConnString
  6.     End With
  7.         sSQl = "SELECT [ÍÖæÑ] FROM [ÊæÞíÊÇÊ ÇáÅÏÇÑí] WHERE [ÇÓã ÇáÚÇãá] = '" & lstMngment.List(lstMngment.ListIndex) & "' AND [ÊÇÑíÎ ÇáÏÎæá] = #" & Format(Now, "dd/mm/yy") & "#"
  8.         rsTempRecordSet.Open sSQl, cnTeamCMI, adOpenStatic, adLockReadOnly
  9.     With rsTempRecordSet
  10.         If .Fields("ÍÖæÑ") = "ÅÌÇÒÉ" Then
  11.         cmdMGTHoliday.Enabled = False
  12.         Else
  13.         cmdMGTHoliday.Enabled = True
  14.         End If
  15.     End With
  16. rsTempRecordSet.Close
  17. 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 !