By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,996 Members | 884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,996 IT Pros & Developers. It's quick & easy.

Parameter dialog box

P: 1
Hi, I have created databases. But, I am green when it comes fixing damaged Access databases. I am trying to change a parameter dialogue box in a form. Then create a link to the reports (with the ability to print just that report) from the database. So far, this what I have....
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdOK_Click()
  2. Const cInvalidDateError As String = "You have entered an invalid date."
  3. Dim strWhere As String
  4. Dim strError As String
  5.  
  6.     strWhere = "1=1"
  7.     strReports = "Reports.[lstReports]"
  8.  
  9.     'If StartDate
  10.     If IsDate(Me.txtStartDate) Then
  11.         'Add it to the predicate - exact
  12.         strWhere = strWhere & " AND " & "Issues.[Opened Date] >= " & GetDateFilter(Me.txtStartDate)
  13.     ElseIf Nz(Me.txtStartDate) <> "" Then
  14.         strError = cInvalidDateError
  15.     End If
  16.  
  17.     'If EndDate
  18.     If IsDate(Me.txtEndDate) Then
  19.         'Add it to the predicate - exact
  20.         strWhere = strWhere & " AND " & "Issues.[Opened Date] <= " & GetDateFilter(Me.txtEndDate)
  21.     ElseIf Nz(Me.txtEndDate) <> "" Then
  22.         strError = cInvalidDateError
  23.     End If
  24.  
  25.     If strError <> "" Then
  26.         MsgBox strError
  27.     Else
  28.         DoCmd.OpenReport strReport, acViewPreview, , strWhere
  29.     End If
  30.  
  31.     Me.frmWhatDates = strWhere
  32.     Me.frmWhatDates.FilterOn = True
  33.  
  34.     End If
  35.  
  36. End Sub
  37.  
  38. Function GetDateFilter(dtDate As Date) As String
  39.     ' Date filters must be in MM/DD/YYYY format
  40.     GetDateFilter = "#" & Format(dtDate, "MM/DD/YYYY hh:mm:ss AM/PM") & "#"
  41. End Function
  42.  
May 14 '07 #1
Share this Question
Share on Google+
1 Reply


MMcCarthy
Expert Mod 10K+
P: 14,534
This question has been moved to the Access forum from Introductions forum.

ADMIN
May 15 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.