Results 1 to 11 of 11
  1. #1
    Shadows1989 is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    15

    Run-time error: 2448

    Hi,

    Can anyone assist with this error please? I am trying to update a field in my subform, from a field in my subform, details of which can be seen here: https://www.accessforums.net/showthread.php?t=78630.

    I've created the unbound text boxes and set the control source to the field on the main form. My code looks like so:

    Code:
    Private Sub IL1_Code_AfterUpdate()With Me.frm_Publishing_Info_Subform.Form
        !Publisher_IL1 = Me.IL1_Code
        .Dirty = False
    End With
    With Me.frm_BookMaster_Control_Files_Subform.Form
        !New_IL1_Code = Me.IL1_Code
        .Dirty = False
    End With
    End Sub
    When I change the text box in the main form, I get the following error:



    Code:
    Run-time error: 2448
    
    You can't assign a value to this object.
    I then have this highlighted in error in yellow:

    Code:
    !New_IL1_Code = Me.IL1_Code
    I have set the field New_IL1_Code to Enabled = False as I don't want the user to be able to change the data. I want the data to be displayed and that's it.

    Any help please?

    Thanks!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    I tested code and works for me. If you want to provide db for analysis, follow instructions at bottom of my post.
    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.

  3. #3
    Shadows1989 is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    15
    Quote Originally Posted by June7 View Post
    I tested code and works for me. If you want to provide db for analysis, follow instructions at bottom of my post.
    Hi,

    Thanks for your reply. The code doesn't for me, I am trying to attach the file via your instructions but it says my zip file is too big, it is 1.7mb and it says the limit is 500kb. I've uploaded it here for now: https://gofile.io/?c=yvDBvA. Confidential data has been removed.

    What I am trying to do is, on the main CRM form, there are two fields, IL1 Code and IL2 Code. Whenever this data is changed or updated, I want it to update the field Publisher IL1 and Publisher IL2 in the subform Publisher Info. I also want IL1 Code and IL2 Code on the main form, to update Item Level 1 Code and Item Level 2 Code on the subform called Control File.

    I am aware that Item Level 2 Code is duplicated on Control File, this is because it needs to get created in separate places on our bespoke system, so this final tab, is like a check list to ensure things are done.

    As previously mentioned, I've setup the text boxes to have a control source, taken from the main form:

    Code:
    =[Forms]![frm_Publisher_Setup]![IL1_Code]
    And in VBA, I have this, in the AfterUpdate section:

    Code:
    Private Sub IL1_Code_AfterUpdate()
    With Me.frm_Publishing_Info_Subform.Form    !Publisher_IL1 = Me.IL1_Code
        .Dirty = False
    End With
    End Sub
    Which I changed to this:

    Code:
    Private Sub IL1_Code_AfterUpdate()
    With Me.frm_Publishing_Info_Subform.Form
        !Publisher_IL1 = Me.IL1_Code
        .Dirty = False
    End With
    With Me.frm_BookMaster_Control_Files_Subform.Form
        !New_IL1_Code = Me.IL1_Code
        .Dirty = False
    End With
    End Sub
    When I change the text box in the main form, I get the following error:

    Code:
    
    Run-time error: 2448
    
    You can't assign a value to this object.
    
    I then have this highlighted in error in yellow:

    Code:
    !New_IL1_Code = Me.IL1_Code

    I have set the field New_IL1_Code to Enabled = False as I don't want the user to be able to change the data. I want the data to be displayed and that's it.

    Let me know if you require any further information.

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,405
    You can't programatically change a field that has a formula for its control source. So just make it unbound.
    Click image for larger version. 

Name:	Shad.png 
Views:	24 
Size:	38.4 KB 
ID:	40069

  5. #5
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by Shadows1989 View Post
    I am trying to attach the file via your instructions but it says my zip file is too big, it is 1.7mb and it says the limit is 500kb.
    Are you sure it was zipped? The limit for accdb files is 500KB but the limit for .zip files says it's 2MB.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    @davegri, field doesn't have formula, textbox has formula. Can certainly set field to a value with VBA. But must say it is not necessary for textbox to have expression that references main form control. Bind textboxes to fields and use VBA to save calculation to field or textbox. Bound control will reflect saved value.

    Posted code that has error is not actually in the procedure. I added it and tested. Code is referencing textbox New_IL1_Code that has an expression. There is no field in RecordSource with that name. What field do you want this value saved in?


    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
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,405
    @davegri, field doesn't have formula, textbox has formula. Can certainly set field to a value with VBA.
    Pardon my semantics, I think the OP will get the idea. Indeed, the OP's submitted DB did not include the code that caused the error he wished to correct. The problem code is in Post#3. I included it, found the error and the suggestion in my post#4 will fix it.

  8. #8
    Shadows1989 is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    15
    Quote Originally Posted by June7 View Post
    @davegri, field doesn't have formula, textbox has formula. Can certainly set field to a value with VBA. But must say it is not necessary for textbox to have expression that references main form control. Bind textboxes to fields and use VBA to save calculation to field or textbox. Bound control will reflect saved value.


    Posted code that has error is not actually in the procedure. I added it and tested. Code is referencing textbox New_IL1_Code that has an expression. There is no field in RecordSource with that name. What field do you want this value saved in?




    The textbox is called New_IL1_Code that I want changed, I want this to display whatever is in the IL1 Code from the main form.


    Quote Originally Posted by davegri View Post
    Pardon my semantics, I think the OP will get the idea. Indeed, the OP's submitted DB did not include the code that caused the error he wished to correct. The problem code is in Post#3. I included it, found the error and the suggestion in my post#4 will fix it.

    Apologies, I thought I had the code saved in that version. I'm sorry. I thought it had to be bound to the parent source for the child to show the data and then VBA code in to do the update whenever the parent source was changed?


    Quote Originally Posted by pbaldy View Post
    Are you sure it was zipped? The limit for accdb files is 500KB but the limit for .zip files says it's 2MB.

    Yes it was zipped.

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    Read posts 4 and 6 again. Solution is provided.

    Cannot set value of textbox that has an expression in 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.

  10. #10
    Shadows1989 is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    15
    Quote Originally Posted by June7 View Post
    Read posts 4 and 6 again. Solution is provided.

    Cannot set value of textbox that has an expression in ControlSource.
    Can be done. I've done it in my database already.

    In my database, go to design view of frm_Publisher_Setup, then click on the Marketing Template tab, in the field Book Discount Class, you will see:

    Code:
    =[Forms]![frm_Publisher_Setup]![frm_Publishing_Info_Subform].[Form]![Book_Discount_Code].[Column](1)
    This field is driven from frm_publishing_info_subform, field Book Discount Code. There is an Event Procedure in After Update with the following formula:

    Code:
    Private Sub Book_Discount_Code_AfterUpdate()
    Me.Parent![frm_Marketing_Subform].Form.Requery
    End Sub
    So, not only does it display the correct data, but it also updates upon change.

    I am trying to figure out why it doesn't work for other fields.

  11. #11
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,405
    I am trying to figure out why it doesn't work for other fields.
    Apples and oranges. Not the same thing. The example you give merely asks the existing formula in the book discount class to recalculate.
    In the non working examples, you are if effect asking that the formula be ignored, and put THIS into the textbox. No can do.

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

Similar Threads

  1. Replies: 1
    Last Post: 08-25-2015, 02:34 PM
  2. Replies: 0
    Last Post: 05-16-2012, 01:48 PM
  3. Error 2448
    By gtrudel in forum Programming
    Replies: 9
    Last Post: 07-11-2011, 07:30 PM
  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