troubleshooting Question

Convert Date from a form to a crosstab query

Avatar of Doc1505
Doc1505 asked on
Microsoft AccessSQL
3 Comments1 Solution173 ViewsLast Modified:
I have a form that has a text field [date] that is formatted to mm/yyyy
I have a command button that prints a form JIB

Private Sub Command123_Click()
On Error GoTo Err_Command123_Click
SetLegalSize ("JIB")
Dim strReportName As String
    Dim strCriteria As String
       strReportName = "JIB"
    strCriteria = "[Well ID]='" & Me![Well ID Main] & "'"
    DoCmd.OpenReport strReportName, acPreview, , strCriteria
Exit_Command123_Click:
    Exit Sub

Err_Command123_Click:
    MsgBox Err.Description
    Resume Exit_Command123_Click
End Sub

The report uses a crosstab query that I have transferring the date to it like
[Forms]![JIBCharges]![Date]

The problem I am having is that it will not convert the date to YYYY only, this causes the crosstab query to have more records, because it lists jan, feb, mar, etc,  not just the year combine.  
I have tried Forms!JIBCharges!Date.Format = "yyyy"
I can do this with the crosstab prompting me for the YYYY but would rather have it not prompt me.

Expr2: Format([Date],"yyyy")
Group by
Row Heading

Format([Date],"yyyy")
Where
[Enter Year YYYY]

Expr1: Format([Date],"mmm")
Group by
Column Heading
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros