Results 1 to 13 of 13
  1. #1
    msmithtlh is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    151

    Conditional formating in a report

    I have 2 very similar reports. One is initiated off of an update form, the other is initiated off of an add form.


    In both cases, I have similar data.
    I have the following code on the report which comes from the update screen, which is working as I want to format the IDText field:
    Private Sub Report_Load()
    If Me!IDType = "FEIN" Then
    Report!IDText.InputMask = "##-#######"
    End If

    If Me!IDType = "SSN" Then
    Report!IDText.InputMask = "###-##-####"
    End If

    If Me!IDType = "CERT" Then
    Report!IDText.InputMask = "##-##########-#"
    End If
    If Me!IDType = "BP" Then
    Report!IDText.InputMask = "##########"
    End If
    End Sub

    When I put the same code on the report which comes from the add screen, I get a runtime error 438 "Object doesn't support this property or method."

    I don't understand why it would work on the report from the update screen, but not on the report from the add screen. The button from the update screen runs a query to get the data, then opens a report. The button from the add screen first saves the record, then runs a query to get the data, then opens a report. Very, very similar. I'm stumped. Appreciate your help!!

  2. #2
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Try this

    If Forms!formname.IDType = "FEIN" Then
    Report!IDText.InputMask = "##-#######"
    End If

    If Forms!formname.IDType = "SSN" Then
    Report!IDText.InputMask = "###-##-####"
    End If

    If Forms!formname.IDType = "CERT" Then
    Report!IDText.InputMask = "##-##########-#"
    End If

    If Forms!formname.IDType = "BP" Then
    Report!IDText.InputMask = "##########"
    End If
    End Sub

    Of course swap out formname, for the actual Form name.

  3. #3
    msmithtlh is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    151

    New error

    New error now: 2465 "Application-defined or object-defined error

  4. #4
    msmithtlh is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    151
    Please note, the IDtype field is on a subform. I don't know how the syntax would be for that.

    Form name - Addworklog
    Subform name - Record Requests - addtl data

  5. #5
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Anyway to post the DB here without the sensitive info? I'd like to take a crack at it.

  6. #6
    msmithtlh is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    151
    I tried, but the files exceed the size limit.

    I think the problem with your original suggestion is that the value needed is on the subform (I don't know how to write the expression for a field on a subform).

    Going back to my original situation, the data is the same, just coming in one case from a new record that has just been saved vs coming from a record retrieved in edit mode. Why would the report object (based on the same field in both cases) support the inputmask property in one case and not the other? Error: "Object doesn't support this property or method."

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Did you run Compact & Repair on the db? Remove records? Zip the file? - up to 2mb zip allowed

    Reference to field on subform when code is on main form:
    Me.subformcontainername!fieldname

    Reference to control on subform when code is on main form:
    Me.subformcontainername.Form.controlname

    I always give subform/subreport container control name different from the object held.

    Is this code behind subform? IDType is field and IDText is textbox and both are on subform?

    If Me!IDType = "BP" Then
    Me.IDText.InputMask = "##########"
    End If

    Does report display multiple records? Does it show only one or all IDType? Setting property of control will not work if mixing IDType records.

    This conditional code could be done in query or textbox ControlSource. It will be a lengthy expression (or could be a custom function) to format the data, not set a textbox property.

    IDTextForm: Format([IDText], Switch([IDType]="FEIN", "##-#######", [IDType]="SSN", "###-##-####", [IDType]="CERT", "##-##########-#", [IDType]="BP", "##########"))
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    msmithtlh is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    151
    client.zipDatabase attached (client & data). All data is test data at this point. Thanks!!!

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Want to respond to questions in my previous post? Have you considered the information I provided?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    msmithtlh is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    151
    I don't understand the following: "I always give subform/subreport container control name different from the object held." So, I didn't do anything with that.

    The report only displays one record. It is a page that is printed as a "routing slip" to accompany a work assignment.

    Concerning the code you gave at the end, I'm not sure where you are suggesting I put it. Could it be put in an event?
    Thanks again.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    A subform/subreport is created by placing a subform/subreport container control on another form/report. The container holds an object (SourceObject property). The object can be a table, query, form, report. I always name the container different from the object it holds. Example:

    Report is named OrderDetails so I name the container ctrDetails.

    The code could be in a query to create field with expression or it could be expression in a textbox ControlSource.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    msmithtlh is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    151
    OK. I have a subform called "Record Requests - addtl data" on the form "AddWorkLog," but the report doesn't have a subreport. However, the field that is causing the issue - idtext - does originate on the subform.

    Just for clarification, a new record gets created on the "addworklog" form, with a category of "record requests." The data in both the form (at top) and the subform (on the bottom gets filled in - through the ID fields. Then the button for "routing slip" is pushed, which runs the macro "MacroRouting Slip New" which (1) saves the record, (2) runs the query "routing slip query new" and then opens the report "Routing slip for new"

    A similar process is done with the update process - form: "Update Record Requests," macro: "MacroRoutingSlip Update," query "Routing Slip Query Update," report: "Routing Slip for update." In this process, I have a formatting attached to the load event of the report and

  13. #13
    msmithtlh is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    151
    I found my problem - it was a slight naming discrepancy between the 2 forms, my code worked fine once I fixed the field names. Thanks!!!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Conditional Formating
    By redbull in forum Reports
    Replies: 2
    Last Post: 03-26-2012, 12:08 PM
  2. Conditional Formating help
    By Mounds in forum Forms
    Replies: 2
    Last Post: 02-10-2012, 11:07 AM
  3. Conditional formating!
    By karanvemuri in forum Access
    Replies: 3
    Last Post: 10-29-2011, 03:34 PM
  4. Conditional Formating (Report Field)
    By mlawson6128 in forum Programming
    Replies: 1
    Last Post: 03-10-2011, 11:23 PM
  5. Conditional Formating In A Report
    By cadsvc in forum Reports
    Replies: 11
    Last Post: 11-02-2010, 04:47 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums