Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check a column of dates? 1

Status
Not open for further replies.

Trevoke

Programmer
Jun 6, 2002
1,142
US
Hi. I have about 3 weeks of experience with Access 97, and I realize that this question is probably easy, but I'm stumped all the same :)

- I have a table (tblLauder) that has a PkgDue variable that stores when the package is due. I need to cycle through all of the dates at startup to see if any are due today. There is also a BatchStartBy and a ComponentsNeededBy that I need to check for today's date.
Upon meeting a date match, I need a MsgBox to pop up displaying tblLauder.Code, tblLauder.Shade, and tblLauder.Comments, if possible on separate lines.

- About BatchStartBy and ComponentsNeededBy...
I store in tblConfig two numeric values, BatchStartedBy and ComponentsNeededBy (I know, I lacked imagination) that hold the number of days before the due date when we need to get the components and when we need to start the batch.

Thanks for your time! Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane mittam.
 
'I don't know the name of all you fields, however this is the way you read record by 'record in a table. Insert other fields you want to know information for:

Dim dbs As Database
Dim rstLauder As Recordset
Dim PkgDue

Set dbs = CurrentDb
Set rstLauder = dbs.OpenRecordset("tblLauder")

'Do until you get to the last record

Do Until rstLauder.EOF

PkgDue = rstUser!PkgDue

If PkgDue = Date Then
MsgBox("Field Number this is due " & PkgDue)
Else
If rstLauder.EOF = False Then
rstLauder.MoveNext
End If
End If

Loop
 
Thank you very much. One more step on the path towards enlightenment and programming mastery.

You have become better at Coding! (17) Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane mittam.
 
Instead of looping through the entire database all the time, base it off of a query:

Function fndxxx() As Boolean


Dim dbs As Database
Dim rstLauder As Recordset
Dim PkgDue
Dim strSQL As String

strSQL = "SELECT * FROM tblLauder WHERE PkgDue = #" & Date & "#;"
Set dbs = CurrentDb
Set rstDueToday = dbs.openrecordset(strSQL)

If rstDueToday.RecordCount = 0 Then
MsgBox ("None due today")
Exit Function
End If
rstDueToday.MoveFirst
Do Until rstDueToday.EOF
<code here to do what you want>
rstDueToday.MoveNext
Loop
End Function
 
Heh. One more question. After fiddling around, I decided to try the SQL way, which is less &quot;programmer&quot; and more &quot;database&quot;..

Nonetheless, since I am still more &quot;programmer&quot; than &quot;database&quot; here's my question ;)

How can I create this StrSQL so that I can put an OR statement in it? that is.. StrSQL = Select... where shipdate = date or batchdate = date or ... etc.. ?

Thanks for your time! Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane mittam.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top