Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2006
    Posts
    2

    Unanswered: Header on each page

    I've designed a report with a header which has a special title that it depends on two previous form's textbox: monthx and yearx

    In the report there is a textbox named: period
    In the report's Open event procedure:

    Private Sub Report_Open(Cancel As Integer)
    Me!period.ControlSource = "='" _
    & Forms!FormName!monthx & "'" + "/" & Forms!FormName!yearx & "'"
    End Sub

    But it gave me a sintaxis error
    I need show the period as : "February/2006"
    Please help me
    Thanks in advance,
    CM

  2. #2
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    Most likely becasue you are using the + instead of the &

    Use + when you are numerically adding things together to get a single result.
    Use the & when you are assembling things into a string.

    Personally, I'd use a label and assign the specific text you want to the caption property - No need for Access to "calculate" the value on each page.

    Have fun!

  3. #3
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Dates

    Could you enter something like this:

    Me!period.ControlSource = "='" _
    & format(Forms!FormName!myDateField,"mmmm/yyyy")

    verses

    & format(Forms!FormName!monthx & "'" + "/" & Forms!FormName!yearx & "'"
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  4. #4
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    As far as I can tell, you have an odd number of single quotes. One after the =, one after the month, and one after the year. This should work:

    Me!period.ControlSource = "='" & Forms!FormName!monthx & "/" & Forms!FormName!yearx &"'"

  5. #5
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    ersonally, I'd use a label and assign the specific text you want to the caption property - No need for Access to "calculate" the value on each page.
    Since you are already using code to get the value on the report, use the code to set the actual value instead of using code to assign an expression, which Access has to then evaluate on each page.

    Less steps, less to debug if it doesn't work right.

    Make period a label and set your code to:
    Code:
    Private Sub Report_Open(Cancel As Integer)
        Me.period.Caption = Forms!FormName!monthx & "/" & Forms!FormName!yearx
    End Sub
    This assumes that both monthx and yearx are text value and not date values.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •