Problem in date!!!!

I have a problem regarding date. In my program I CANT SAVE THE DATE 1-12 but when it come 13 - 31 of the month it can save..

Dim Cmd As New Command
Dim RsGrid As New Recordset
Dim rs1 As New ADODB.Recordset
Dim RS As New ADODB.Recordset
'Private Sub cmdAdd_Click()
'If (Trim(Text1.Text = "")) Then
'MsgBox "Please select a name from list", vbCritical, "Attendance"
'Exit Sub
'End If
'cmdAdd.Visible = False
'cmdSave.Visible = True
'cmdCancel.Visible = True
'End Sub
Private Sub cmdCancel_Click()
cmdAdd.Visible = True
cmdSave.Visible = False
cmdCancel.Visible = False
End Sub

Private Sub Label12_Click()
Label12.Caption = Text3.Text & " "
End Sub

Private Sub Text1_KeyDown( _
KeyCode As Integer, Shift As Integer)
Dim str1, str2, str3 As String
Select Case KeyCode
Case vbKeyReturn:

If (Trim(Text1.Text = "")) Then
MsgBox "Please select a name from list", vbCritical, "Attendance"
End If

If Text1.Text = Trim("") Then
MsgBox "Name could not be blank ", vbCritical, "Attendance"
Text1.Text = ""
Exit Sub
End If
FindIncoming
ddd = txtTDate.Text
rs1.Open "select * from attend where name='" & Text1.Text & "' and tdate= #" & CDate(txtTDate.Text) & "#", CN
'rs1.Open "select * from attend where name='" & Text1.Text & "' and tdate= #" & txtTDate.Text & "#", CN
If Not rs1.EOF Then
MsgBox "Could not add the same attendance twice for" & " " & Text1.Text, vbCritical, "Attendance"
Text1.Text = ""
cmdAdd.Visible = True
cmdSave.Visible = False
cmdCancel.Visible = False
rs1.Close
Exit Sub
End If
rs1.Close
If RS.State = adStateOpen Then
RS.Close
End If

RS.Open "select * from attend", CN
RS.AddNew
RS("name") = Text1.Text
RS("incoming") = CDate(txtIncoming.Text)
'RS("incoming") = txtIncoming.Text
RS("tdate") = txtTDate.Text

RS.Update
str2 = Text1
Adodc1.Recordset.Filter = "EmployeeNo ='" & str2 & "'"

FillGrid
RS.Close
Text1.Text = ""
'cmdAdd.Visible = True
'cmdSave.Visible = False
'cmdCancel.Visible = False
End Select
Image1.Picture = LoadPicture(Text2.Text)
Image1.Stretch = True
End Sub
Private Sub Form_Load()
ModuleConn.AttendConn
RefreshIncoming
FillGrid

End Sub
Private Sub Form_Unload(Cancel As Integer)
ModuleConn.CloseConn
Unload Me
frmMain.Show
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = True
Text1.SetFocus
txtIncoming.Text = Format(Now, "hh:mm:ss AM/PM")
txtTDate.Text = Format(Now, "dd-MMM-yy")
Label1.Caption = txtTDate.Text
Label5.Caption = txtIncoming.Text
End Sub
Private Sub RefreshIncoming()
If RS.State = adStateOpen Then
RS.Close
End If
RS.CursorLocation = adUseClient
RS.CursorType = adOpenStatic
RS.LockType = adLockOptimistic
RS.Open "select distinct name from attend", CN
If RS.RecordCount > 0 Then
RS.MoveFirst
While Not RS.EOF
'cboName.AddItem RS("name")
Text1.Text = ""
RS.MoveNext
Wend
RS.Close
End If
End Sub
Private Sub FindIncoming()
If rs1.State = adStateOpen Then
rs1.Close
End If
rs1.CursorLocation = adUseClient
rs1.CursorType = adOpenDynamic
rs1.LockType = adLockOptimistic
End Sub
Private Sub FillGrid()
If RsGrid.State = adStateOpen Then
RsGrid.Close
End If
RsGrid.CursorLocation = adUseClient
RsGrid.CursorType = adOpenStatic
RsGrid.LockType = adLockOptimistic

RsGrid.Open "select name from attend where tdate = #" & Date & "#", CN



If RsGrid.RecordCount > 0 Then
RsGrid.MoveFirst
Set DataGrid1.DataSource = RsGrid
End If

End Sub

Private Sub Timer2_Timer()

Label12.Caption = Mid(Label12.Caption, 2) & Mid(Label12.Caption, 1, 1)
'" & Date & "

End Sub
Here is the saple code of my programm.
I hope you can help me regarding this matter
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories