DateFromServer and date replace module

tanatif

Registered User.
Local time
Today, 13:28
Joined
Feb 10, 2016
Messages
40
please help me to fix this code
this is working with mdb database and date() i wont working in sql
i try every thing is working great but the date() i wont change to DateFromServer() its not working

Code:
Private Sub Form_Load()

Dim intStore As Integer

intStore = DCount("[id_amlyat]", "[form_amlyat]", "[date end] <=[COLOR="Red"]Date()[/COLOR]+2 AND [check_box] =-1 ")

    If intStore = 0 Then
    
Exit Sub
Else

If MsgBox("found  " & intStore & "title " & _
          "remaining 48 hours " & vbCrLf & vbCrLf & _
          "                                             " & _
          " do you wont continue? " & _
          " ", vbYesNo Or vbExclamation Or vbDefaultButton1, _
          "alert") = vbYes Then
          
          DoCmd.OpenForm "Qremeber_amlyat", acNormal
      Else
     Exit Sub
End If
End If
End Sub



Code:
Private Sub Form_Load()

Dim intStore As Integer

intStore = DCount("[id_amlyat]", "[form_amlyat]", "[date end] <=[COLOR="SeaGreen"]DateFromServer()[/COLOR]+2 AND [check_box] =-1 ")

    If intStore = 0 Then
    
Exit Sub
Else

If MsgBox("found  " & intStore & "title " & _
          "remaining 48 hours " & vbCrLf & vbCrLf & _
          "                                             " & _
          " do you wont continue? " & _
          " ", vbYesNo Or vbExclamation Or vbDefaultButton1, _
          "alert") = vbYes Then
          
          DoCmd.OpenForm "Qremeber_amlyat", acNormal
      Else
     Exit Sub
End If
End If
End Sub


DateFromServer() module

Code:
Public Function DateFromServer() As String
DateFromServer = DLookup("MASARDATE", "MASARDATE")
End Function

please help me
 
attachment.php
 

Attachments

  • datedatedate.jpg
    datedatedate.jpg
    30.8 KB · Views: 210
or this

Code:
Private Sub Form_Load()

Dim intStore As Integer

smsm = DLookup("MASARDATE", "MASARDATE")
Dim smsm As Integer

intStore = DCount("[id_amlyat]", "[form_amlyat]", "[date end] <=[COLOR="Purple"]smsm[/COLOR]+2 AND [check_box] =-1 ")

    If intStore = 0 Then
    
Exit Sub
Else

If MsgBox("found  " & intStore & "title " & _
          "remaining 48 hours " & vbCrLf & vbCrLf & _
          "                                             " & _
          " do you wont continue? " & _
          " ", vbYesNo Or vbExclamation Or vbDefaultButton1, _
          "alert") = vbYes Then
          
          DoCmd.OpenForm "Qremeber_amlyat", acNormal
      Else
     Exit Sub
End If
End If
End Sub

:banghead: ?
 
The function and module must not have the same name.
 
Your function needs to return a Date rather than a string.

Code:
Public Function DateFromServer() As [B]Date[/B]
DateFromServer = DLookup("MASARDATE", "MASARDATE")
End Function
 
Your function needs to return a Date rather than a string.

Code:
Public Function DateFromServer() As [B]Date[/B]
DateFromServer = DLookup("MASARDATE", "MASARDATE")
End Function

but the DCount not working its result all time =0 :confused:

and MsgBox not working becouse the result not change


Code:
Private Sub Form_Load()

Dim intStore As Integer

intStore = DCount("[id_amlyat]", "[form_amlyat]", "[date end] <=DateFromServer()+2 AND [check_box] =-1 ")

    If intStore = 0 Then
    
Exit Sub
Else

If MsgBox("found  " & intStore & "title " & _
          "remaining 48 hours " & vbCrLf & vbCrLf & _
          "                                             " & _
          " do you wont continue? " & _
          " ", vbYesNo Or vbExclamation Or vbDefaultButton1, _
          "alert") = vbYes Then
          
          DoCmd.OpenForm "Qremeber_amlyat", acNormal
      Else
     Exit Sub
End If
End If
End Sub
 
yes here is problems if i remove

AND [check_box] =-1

Code:
Private Sub Form_Load()

Dim intStore As Integer

intStore = DCount("[id_amlyat]", "[form_amlyat]", "[date end] <=DateFromServer()+2 ")

    If intStore = 0 Then
    
Exit Sub
Else

If MsgBox("found  " & intStore & "title " & _
          "remaining 48 hours " & vbCrLf & vbCrLf & _
          "                                             " & _
          " do you wont continue? " & _
          " ", vbYesNo Or vbExclamation Or vbDefaultButton1, _
          "alert") = vbYes Then
          
          DoCmd.OpenForm "Qremeber_amlyat", acNormal
      Else
     Exit Sub
End If
End If
End Sub

its working

but i wont use this to select that

Code:
 AND [check_box] =-1
 
Last edited:
Try the below:
Code:
intStore = DCount("[id_amlyat]", "[form_amlyat]", "[date end] <=" & DateFromServer()+2 & " AND [check_box] =-1 ")
 
Try the below:
Code:
intStore = DCount("[id_amlyat]", "[form_amlyat]", "[date end] <=" & DateFromServer()+2 & " AND [check_box] =-1 ")

thank you for try with me but not working try again please?
:(
 
Code:
intStore = DCount("[id_amlyat]", "[form_amlyat]", "[date end] <=DateFromServer() AND [check_box] =[COLOR="Red"]True [/COLOR]")

yes yes yes :D

i try and try and try

i change =-1 to =True

and its working good in sql server the last =-1 its working only with mdb or accdb

thanks for all freinds
 

Users who are viewing this thread

Back
Top Bottom