Results 1 to 10 of 10
  1. #1
    gtrudel is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    4

    Error 2448

    I "inherited" an access app that manages a golf league. Each week, cards are produced depending on whether the league is playing the front or back. The report renders correctly and the data displays correctly. When I do a print preview I get the error 2448 with the error message on the code that puts the appropriate yardage in the first box. Here is the code:

    Private Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)
    Dim db As Database
    Dim rec As Recordset
    Set db = CurrentDb
    Set rec = db.OpenRecordset("course")
    Dim x As Long
    Dim y As Long
    Dim holex As Long
    If Me.[Front/Back] = 1 Then
    holex = 0
    Else
    holex = 9
    End If
    With rec
    Do Until .EOF


    Select Case Left(rec!Hole, 1)
    Case "b"
    y = 0
    For x = 1 To 9
    Me("B" & x) = rec("[" & x + holex & "]")

    The last entry is where the debugger stops. The cards are fine in the report view. The print and/or print preview has the issue

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    so it errors on the last line? define "last entry"

    if so, the first thing I notice is that you're concating a string and a long. that shouldn't work, in theory.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602
    The concatenation can be done. Will it make sense?
    This: "ABC" & 3456.7 will result in: ABC3456.7
    This: "12" & "15" will result in: 1215
    This: 12 & 15 will result in: 1215
    This: "ABC" + 3456.7 will error
    This: "12" + 15 will result in: 27
    This: "12" + "15" will result in: 1215

    This is because the + sign is holdover concatenation operator from ancient Basic as well as sum operator. Must be careful with it.

    You are trying to dynamically build form control name and recordset field name or field index. I do this. Your syntax is wrong. Try: Me.Controls("B" & x) = rec.Fields("[" & x + holex & "]")

    Is the x + holex to build a field name or field index?
    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.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    I don't see a problem offhand. The + is adding two numeric variables to account for front or back 9 (golf terms), the & concatenation is putting brackets around what I assume is the field name (1-18, for the 18 holes). Error 2448 if I'm not mistaken relates to not being able to assign a value to the object. What are the controls named "B1", etc. If they're labels, they don't have a value property to assign (you can use the caption). If they're textboxes, what is the control source?

    By the way, the reason it "works" in Report view is that the detail format event doesn't fire in Report view. I assume the boxes are not filled in?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    gtrudel is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    4

    Report Cards

    Sorry - couldn't resist. The interesting aspect is that in report view all of the boxes are filled in. the control source for each box is a formula which displays the yardage for each hole depending on whether it is the front or back. Here is a sample - =IIf([Front/Back]="1","331","323"). This report replicates the cards from the course that contains the yardage from each of the marker - blue, white, red and the par for the hole. As I stated, the report renders just fine, but when I try to do anything from the print menu, I get the error "you can't assign a value to this object". Further, when I stop the debugger, I get a message stating that the "a custom macro in this report has failed and is preventing the report from rendering". Yet again, I can see all of the values in the report view. Thanks for the quick responses.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602
    Ooops! Just hit me that this code attempts to set value of a field or unbound textbox in a report. Don't think can do that. I have tried. Once a report starts to open, data can't be changed. The Detail_Format event can be used to modify display properties, such as make textboxes visible or not visible, but not set values of textboxes. You can call a custom function from a report textbox or refer to controls of an open form to get data.
    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.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    The reason your code fails is because the textboxes have that control source. If you remove it, the code might work. You can set the value of an unbound textbox in the detail format event (just tested).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602
    I stand corrected. I just did a test also. Find that the value shows only in PrintPreview view. Guess I never tested that before. And, to my surprise, gtrudel's original syntax worked. Learn something new everyday. Seems there was some reason I had to use .Controls and .Fields in my project and will have to go back and verify that.

    Also interesting that when I step debug I see the Detail_Format event is run twice.

    So the issue is trying to change value of bound textbox.
    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.

  9. #9
    gtrudel is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    4

    Error 2448 - Resolved

    Hi
    First, thanks to all for the responses. Your comments pointed me to the properties on the detail report. The on-format property had the event procedure which pointed to the code that was abending. I removed this entry and the report rendered and printed correctly. THANKS again.

    George

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Glad you got it sorted out George. Basically you were trying to do the same thing 2 different ways and they conflicted with each other.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Error 13 Type Mismatch error
    By GlennBurg in forum Programming
    Replies: 1
    Last Post: 06-21-2011, 03:05 AM
  2. Replies: 8
    Last Post: 05-16-2011, 06:01 PM
  3. Replies: 2
    Last Post: 12-02-2010, 02:35 AM
  4. Replies: 3
    Last Post: 04-15-2010, 09:43 AM
  5. runtime error 2448
    By ds_8805 in forum Forms
    Replies: 3
    Last Post: 04-14-2010, 07:32 PM

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