Switchboard

G

Guest

I have created a switchboard that allows the user to select records that are
due within 30, 60 or 90 days.

Below is the event procedure for records due in 90 days. It is pulling from
the "Due Date" field. However, it is not pulling records 30 days after
today's date. It's pulling records either prior to or after today's day.
How do I fix this problem?

Private Sub Option4_Click()
Setdate2 ("-30")
End Sub
 
G

Guest

I have added this code but am still getting an syntax error message on the
last line.

Public Sub Setdate2(Mydate As Integer)
'MsgBox ("Mydate:" & Mydate)
dtmIncludeDate = DateAdd("d", Mydate, Date)
strWhere = "[Boeing Response Due Date] >= #" & Date & "# and [Boeing
Response Due Date] <=" & dtmIncludeDate & "#"
'DoCmd.OpenForm "Master Data Form1"
DoCmd.OpenForm "Master Data Form1", , , strWhere
End Sub
 
J

John Vinson

I have created a switchboard that allows the user to select records that are
due within 30, 60 or 90 days.

Below is the event procedure for records due in 90 days. It is pulling from
the "Due Date" field. However, it is not pulling records 30 days after
today's date. It's pulling records either prior to or after today's day.
How do I fix this problem?

Private Sub Option4_Click()
Setdate2 ("-30")
End Sub

What on Earth is Setdate2? It's not an Access function, and you have
not chosen to let us in on its secret. What's the recordsource for the
form?

John W. Vinson[MVP]
 
G

Guest

I'm already using Setdate to query records so now I'm using Setdate2 to query
another set of records. This is what I have:

Public Sub Setdate(Mydate As Integer)
'MsgBox ("Mydate:" & Mydate)
dtmIncludeDate = DateAdd("d", Mydate, Date)
strWhere = "[DateModified] >= #" & dtmIncludeDate & "#"
'DoCmd.OpenForm "Master Data Form1"
DoCmd.OpenForm "Master Data Form1", , , strWhere
End Sub

Public Sub Setdate2(Mydate As Integer)
'MsgBox ("Mydate:" & Mydate)
dtmIncludeDate = DateAdd("d", Mydate, Date)
strWhere = "[Boeing Response Due Date] >= #" & Date & "# and [Boeing
Response Due Date] <=" & dtmIncludeDate & "#"
'DoCmd.OpenForm "Master Data Form1"
DoCmd.OpenForm "Master Data Form1", , , strWhere
End Sub



Private Sub Option1_Click()
'MsgBox ("This Better Work")
Setdate ("-7")
End Sub

Private Sub Option2_Click()
Setdate ("-30")
End Sub

Private Sub Option3_Click()
Setdate ("-60")
End Sub

Private Sub Option4_Click()
Setdate2 ("+30")
End Sub

Private Sub Option5_Click()
Setdate2 ("+60")
End Sub

Private Sub Option6_Click()
Setdate2 ("+90")
End Sub

Private Sub O()
ption7_Click()
Setdate2 ("-60")
End Sub
 
J

John Vinson

I'm already using Setdate to query records so now I'm using Setdate2 to query
another set of records. This is what I have:

Public Sub Setdate(Mydate As Integer)
'MsgBox ("Mydate:" & Mydate)
dtmIncludeDate = DateAdd("d", Mydate, Date)
strWhere = "[DateModified] >= #" & dtmIncludeDate & "#"
'DoCmd.OpenForm "Master Data Form1"
DoCmd.OpenForm "Master Data Form1", , , strWhere
End Sub

Public Sub Setdate2(Mydate As Integer)
'MsgBox ("Mydate:" & Mydate)
dtmIncludeDate = DateAdd("d", Mydate, Date)
strWhere = "[Boeing Response Due Date] >= #" & Date & "# and [Boeing
Response Due Date] <=" & dtmIncludeDate & "#"
'DoCmd.OpenForm "Master Data Form1"
DoCmd.OpenForm "Master Data Form1", , , strWhere
End Sub

You've defined Mydate as an Integer, but you're passing a String.

Try

Call Setdate2(-30)

Hm. Looking at your code again - that will return all records where
[Boeing Response Due Date] is later than today, and at the same time
earlier than 30 days before today. Of course no date in history can
ever meet both those criteria. Isn't your logic backwards? Do you want
= dtmIncludeDate and <= Date instead?

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top