Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

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