asked on
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
Sub UpdateCustomerOrderDate(lngCustomerID As Long)
'update the order date criteria in the order table
'On Error GoTo Error_Handler
'declare recordsets and connections ->
Dim db As Database
Dim rs1 As DAO.Recordset
Dim rs2 As DAO.Recordset
'setting objects ->
Set db = CurrentDb
Set rs1 = db.OpenRecordset("SELECT * FROM tblOrders WHERE (((tblOrders.CustomerID)=" & lngCustomerID & "))", dbOpenDynaset)
Set rs2 = rs1.Clone
'validate recordset count ->
If rs1.RecordCount > 0 Then
'move to first record ->
rs1.MoveFirst
rs2.Bookmark = rs1.Bookmark
rs2.MoveNext
'check the number of days between the customer order dates ->
If DateDiff("d", rs1.Fields("OrderDate"), rs2.Fields("OrderDate")) <= 30 Then
'set the flag value to 1
With rs1
.Edit
!OrderDateFlag = 1
.Update
End With
Else
'set the flag value to 0
With rs1
.Edit
!OrderDateFlag = 0
.Update
End With
End If
End If
'error handler ->
Err_Handler_Exit:
rs1.Close
rs2.Close
Set rs1 = Nothing
Set rs2 = Nothing
Exit Sub
Error_Handler:
If Err.Number = 0 Then
Resume Err_Handler_Exit
Else
MsgBox ("Error " & Err.Number & " (" & Err.Description & ")"), vbOKOnly
Resume Err_Handler_Exit
End If
End Sub
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.
TRUSTED BY
So what are you wanting to achieve? Looking at the two tables in your database sample, they are both identical...
If you are simply wanting to loop through the table, I can write some code for you to do that but it doesn't solve anything. You need to get more specific about your objective here so we can help you.
~Tala~