|
-
Jan 29th, 2002, 02:46 PM
#1
Thread Starter
Addicted Member
sql query help
hey there,
ive been working on some enhancements of our works access based customer database.
background: a customer is added to the database, the date is filled as the take on date(cdate), when added the customer takes one or more modules (choice of three), the date the module is taken is also auto filled (Module?AddedDeletedDate). what is required is a report of the additional modules in a given date period.
ive managed to get it to show the added modules between the specified dates but the problem is this-if a customer is registered and takes module one, then two weeks later takes module 2, then 6 months later takes module 3. if a report is generated for the date range covering the addition of module three then the report also shows the addition of module two when it is only required to show the most recent module addition.
dont know if im making sense but here is the what i have done so far:
Code:
Private Sub cmdModules_Click()
'Perpares a database sheet detailing all modules added or
'removed in the given date period
Dim date1 As String
Dim date2 As String
Dim continue As Boolean
Dim retvalue As Variant
On Error GoTo Err_Module_Sheet_Click
Call getDates(date1, date2, continue)
If continue = True Then
Call DelTables("DBSHEET")
DoCmd.RunSQL ("SELECT SortCode,Q6Code,Area,CustomerName,Module1") & _
(", Module2, Module3,Module1AddedDeletedDate,Module2AddedDeletedDate") & _
(",Module3AddedDeletedDate,Module1Added,Module2Added,Module3Added,cdate ") & _
(" INTO DBSHEET") & _
(" FROM Customer ") & _
("WHERE Module1AddedDeletedDate > cdate") & _
(" AND( Module1AddedDeletedDate >= #" & date1 & "# AND Module1AddedDeletedDate <= #" & date2 & "#)") & _
(" OR Module2AddedDeletedDate > cdate") & _
(" AND( Module2AddedDeletedDate >= #" & date1 & "# AND Module2AddedDeletedDate <= #" & date2 & "#)") & _
(" OR Module3AddedDeletedDate > cdate") & _
(" AND( Module3AddedDeletedDate >= #" & date1 & "# AND Module3AddedDeletedDate <= #" & date2 & "#)") & _
(" AND Module1Added = True OR Module2Added = True OR Module3Added = True";)
retvalue = MsgBox("Do you wish to print this report ?", vbYesNo, "Printing")
If retvalue = vbYes Then
DoCmd.OpenReport "AdditionalModulesReport", acViewPreview
DoCmd.OpenReport "AdditionalModulesReport", acViewPreview
End If
End If
Exit_Module_Sheet_Click:
Exit Sub
Err_Module_Sheet_Click:
MsgBox Err.Description
Resume Exit_Module_Sheet_Click
End Sub
Any and all help is appreciated
Brian
Last edited by Br1an_g; Jan 29th, 2002 at 05:33 PM.
if you fail to plan, you plan to fail
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|