D
DazedConfused
Your date is set to 20th. Your answer may come then..
:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Command1_Click()
Dim DB As DAO.Database
Dim RS As DAO.Recordset, FLD As DAO.Field
Dim i As Integer
Set DB = CurrentDb()
Set RS = DB.OpenRecordset("tblcheck")
i = 0 'The order of the field [dd] in the table
RS.MoveFirst
Do Until RS.EOF
If (Year(RS.Fields(i).Value) = Year(Now()) And Month(RS.Fields(i).Value) = Month(Now()) And Day
(RS.Fields(i).Value) = Day(Now())) Then
DoCmd.SetWarnings False
DoCmd.RunSQL " Update [tblcheck] Set [code] = [code] + 1 where dd = #" & RS.Fields(i).Value & "#"
DoCmd.SetWarnings True
End If
RS.MoveNext
Loop
Set RS = Nothing
Set DB = Nothing
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
To the second question, we can simply use Docmd.RunSQL to update the [code] field if we click the
Command0 button:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Command0_Click()
DoCmd.SetWarnings False
' If condition Then
DoCmd.RunSQL " Update [tblcheck] Set [code] = [code] + 1 "
DoCmd.SetWarnings True
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Does that answer your question? Please apply my suggestions above and let me know if this helps resolve
your problem. If there is anything more I can do to assist you, please feel free to post it in the group
Best regards,
Billy Yao
Microsoft Online Support
date in the [dd] field. If the date is"Billy Yao [MSFT]" said:Hi Gary,
From your description, I understand that you'd like to realize the two tasks.
According to your questions, I answer them respectively as below:
To the first question, we can use DAO to loop the record and compare the
current date, we then perform a update to the fieldCode:: '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Sub Command1_Click() Dim DB As DAO.Database Dim RS As DAO.Recordset, FLD As DAO.Field Dim i As Integer Set DB = CurrentDb() Set RS = DB.OpenRecordset("tblcheck") i = 0 'The order of the field [dd] in the table RS.MoveFirst Do Until RS.EOF If (Year(RS.Fields(i).Value) = Year(Now()) And[/QUOTE] Month(RS.Fields(i).Value) = Month(Now()) And Day[QUOTE] (RS.Fields(i).Value) = Day(Now())) Then DoCmd.SetWarnings False DoCmd.RunSQL " Update [tblcheck] Set [code] = [code] + 1 where[/QUOTE] dd = #" & RS.Fields(i).Value & "#"[QUOTE] DoCmd.SetWarnings True End If RS.MoveNext Loop Set RS = Nothing Set DB = Nothing End Sub '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' To the second question, we can simply use Docmd.RunSQL to update the [code] field if we click the Command0 button: '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Sub Command0_Click() DoCmd.SetWarnings False ' If condition Then DoCmd.RunSQL " Update [tblcheck] Set [code] = [code] + 1 " DoCmd.SetWarnings True End Sub '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Does that answer your question? Please apply my suggestions above and let me know if this helps resolve your problem. If there is anything more I can do to assist you, please[/QUOTE] feel free to post it in the group
assistance, or I have answered your"Billy Yao [MSFT]" said:Hi Gary,
I'm not sure here "Think" means. Do you mean you need my additional
assistance, or I have answered your"Billy Yao [MSFT]" said:Hi Gary,
I'm not sure here "Think" means. Do you mean you need my additional
= [code] - 2 + " &
RS2.Fields(j).Value
DoCmd.SetWarnings True
RS2.MoveLast
End If
RS2.MoveNext
Loop
Set RS2 = Nothing
Set DB = Nothing
End Sub
''''
Thank you for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know. We are here to be of assistance!
Sincerely yours,
Michael Cheng
Microsoft Online Support
***********************************************************
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks.