HI All,
Now I'm trying to link the dates for 3 tables tblDate, tblStore and tblRepair. So far I've tried this approach:
tbl Date tblRepair
RefDate Date Date RepairID PartsID Repaired TechID
1 1/26/2005 1 1 cable 3 John
2 1/27/2005 1 2 board 6 mike
3 1/28/2005 2 3 wiring 1 mark
tblStore
Date BlcAt(8AM) PartsID Unrepaired Repaired BlcAt(4PM)
1 2 cable 4 3 1
1 7 board 6 6 6
2 3 wiring 2 1 7
The whole database works well, but when I want to print out the reports for a specific date it will only read the RefDate. Is there a way where I can make it read the field Date? Here is the code for looking for the specific date.
Private Sub cmdtoday_Click()
'Sets the Date From and Date To text boxes
'to Today's Date
Me!txtdatefrom = Date
Me!txtDateTo = Date
End Sub
Private Sub cmdweek_Click()
'Sets the Date From and Date To text boxes
'to show complete working week (Mon - Fri)
Dim today
today = Weekday(Date)
Me!txtdatefrom = DateAdd("d", (today * -1) + 2, Date)
Me!txtDateTo = DateAdd("d", 6 - today, Date)
End Sub
Private Sub cmdmonth_Click()
'Sets the Date From and Date To text boxes
'to show complete month (from start to end of current month)
Me!txtdatefrom = CDate("01/" & Month(Date) & "/" & Year(Date))
Me!txtDateTo = DateAdd("d", -1, DateAdd("m", 1, Me!txtdatefrom))
End Sub
Private Sub cmdyear_Click()
'Sets the Date From and Date To text boxes
'to show complete current year
Me!txtdatefrom = CDate("01/01/" & Year(Date))
Me!txtDateTo = DateAdd("d", -1, DateAdd("yyyy", 1, Me!txtdatefrom))
End Sub
Private Sub cmdReport_Click()
On Error GoTo Err_cmdReport_Click
Dim stDocName As String
stDocName = "rptAll"
'Check values are entered into Date From and Date To text boxes
'if so run report or cancel request
If Len(Me.txtdatefrom & vbNullString) = 0 Or Len(Me.txtDateTo & vbNullString) = 0 Then
MsgBox "Please ensure that a report date range is entered into the form", _
vbInformation, "Required Data..."
Exit Sub
Else
DoCmd.OpenReport stDocName, acPreview
End If
Exit_cmdReport_Click:
Exit Sub
Err_cmdReport_Click:
MsgBox Err.Description
Resume Exit_cmdReport_Click
End Sub
Now I'm trying to link the dates for 3 tables tblDate, tblStore and tblRepair. So far I've tried this approach:
tbl Date tblRepair
RefDate Date Date RepairID PartsID Repaired TechID
1 1/26/2005 1 1 cable 3 John
2 1/27/2005 1 2 board 6 mike
3 1/28/2005 2 3 wiring 1 mark
tblStore
Date BlcAt(8AM) PartsID Unrepaired Repaired BlcAt(4PM)
1 2 cable 4 3 1
1 7 board 6 6 6
2 3 wiring 2 1 7
The whole database works well, but when I want to print out the reports for a specific date it will only read the RefDate. Is there a way where I can make it read the field Date? Here is the code for looking for the specific date.
Private Sub cmdtoday_Click()
'Sets the Date From and Date To text boxes
'to Today's Date
Me!txtdatefrom = Date
Me!txtDateTo = Date
End Sub
Private Sub cmdweek_Click()
'Sets the Date From and Date To text boxes
'to show complete working week (Mon - Fri)
Dim today
today = Weekday(Date)
Me!txtdatefrom = DateAdd("d", (today * -1) + 2, Date)
Me!txtDateTo = DateAdd("d", 6 - today, Date)
End Sub
Private Sub cmdmonth_Click()
'Sets the Date From and Date To text boxes
'to show complete month (from start to end of current month)
Me!txtdatefrom = CDate("01/" & Month(Date) & "/" & Year(Date))
Me!txtDateTo = DateAdd("d", -1, DateAdd("m", 1, Me!txtdatefrom))
End Sub
Private Sub cmdyear_Click()
'Sets the Date From and Date To text boxes
'to show complete current year
Me!txtdatefrom = CDate("01/01/" & Year(Date))
Me!txtDateTo = DateAdd("d", -1, DateAdd("yyyy", 1, Me!txtdatefrom))
End Sub
Private Sub cmdReport_Click()
On Error GoTo Err_cmdReport_Click
Dim stDocName As String
stDocName = "rptAll"
'Check values are entered into Date From and Date To text boxes
'if so run report or cancel request
If Len(Me.txtdatefrom & vbNullString) = 0 Or Len(Me.txtDateTo & vbNullString) = 0 Then
MsgBox "Please ensure that a report date range is entered into the form", _
vbInformation, "Required Data..."
Exit Sub
Else
DoCmd.OpenReport stDocName, acPreview
End If
Exit_cmdReport_Click:
Exit Sub
Err_cmdReport_Click:
MsgBox Err.Description
Resume Exit_cmdReport_Click
End Sub