Results 1 to 10 of 10
  1. #1
    DC CS is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Vaalpark, South Africa
    Posts
    69

    error -2147352567 (You can't assign a value to this object.)

    Hi all,


    I am trying to resolve the above error that I receive when opening a report.
    Neither the report nor any control on the report is bound. I need to fill the controls with data retrieved from a table.

    My code as follows:

    Code:
    On Error GoTo Handler:
    
    
    Me.RecordSource = ""
    'Get Report Data++++++++++++++++++++++++++++++++++++++++
    Set Dbs = CurrentDb
    SQL = "SELECT * FROM TmpTableResultReg;"
    Set Rst = Dbs.OpenRecordset(SQL)
    Rst.MoveLast: Rst.MoveFirst
    
    
    CourseDescr = Trim$(Rst!CourseDescr)
    CourseNumber = Rst!CourseNumber
    Facilitator = Trim$(Rst!FacilitatorName)
    Assessor = Trim$(Rst!AssessorName)
    Moderator = Trim$(Rst!ModeratorName)
    The error occurs on the line "CourseDescr = Trim$$(rst!courseDescr)". If I comment this line out, the error occurs at the next line.

    Even if I place a new text control on the report and try to fill the new control, I get the same error.

    What could the problem be?

    Thanks

  2. #2
    Edgar is online now Competent Performer
    Windows 8 Access 2016
    Join Date
    Dec 2022
    Posts
    274
    What are CourseDescr and CourseNumber declared as? What are they supposed to be?
    Please click on the ⭐ below if this post helped you.


  3. #3
    DC CS is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Vaalpark, South Africa
    Posts
    69
    They are declared in the table as follows:
    CourseDescr = Short Text
    CourseNumber = Number (Integer)

    They are not declared in the report (Using the DIM statement) as the controls are 2 Unbound Text Boxes.

  4. #4
    Edgar is online now Competent Performer
    Windows 8 Access 2016
    Join Date
    Dec 2022
    Posts
    274
    Before the line that throws the error type this:
    MsgBox typename(coursedescr) & vbcrlf & typename(coursenumber)
    Let me know what it says...

  5. #5
    DC CS is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Vaalpark, South Africa
    Posts
    69
    Hi Edgar,
    See below result.

    Click image for larger version. 

Name:	Result MsgBox.jpg 
Views:	15 
Size:	8.4 KB 
ID:	51542

  6. #6
    DC CS is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Vaalpark, South Africa
    Posts
    69
    Hi E#dgar,
    I have created a new Access database on my Laptop and created the table and manually populated the fields.
    I then created a report with 3 textboxes, Text0, Text2 and Text4.

    I added the code as above and ran the code with the same result. I cannot assign a value. Even if I try to assign a value before any code runs, I get the same result.

    Not sure what this means.
    Is there a way I can upload this new DB for you to inspect?

    Thanks

  7. #7
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    232
    Why do you use an unbound report If you want to show data from a table?????
    Groeten,

    Peter

  8. #8
    DC CS is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Vaalpark, South Africa
    Posts
    69
    Hi xps35,
    The report is complex and I need to do calculations on other controls in the same report. It is just much easier to get the data from the tables and manipulate the data as and when required.

    I am also using multiple tables in the report. The data does not have any unique fields that I can link to create a query.

    I hope this explains your question.

  9. #9
    DC CS is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Vaalpark, South Africa
    Posts
    69
    Hi all,
    I found the problem.

    I placed the code in the Report_Open event instead of the Load event.

    Thanks for the assistance, and sorry about this mishap. Think I need a break...

  10. #10
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    232
    I still have my doubts. Without knowing the database and the desired output, it remains difficult to assess what the best solution is.
    Look at https://www.accessforums.net/showthread.php?t=70301 to read how to upload your database.
    Groeten,

    Peter

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

Similar Threads

  1. Run-time error -2147352567 (80020009)
    By uoghk in forum Programming
    Replies: 5
    Last Post: 01-10-2022, 06:03 PM
  2. You can't assign a value to this object error
    By bdicarlo1 in forum Forms
    Replies: 6
    Last Post: 11-18-2012, 10:21 AM
  3. Replies: 0
    Last Post: 05-16-2012, 01:48 PM
  4. Replies: 3
    Last Post: 04-15-2010, 09:43 AM
  5. Replies: 3
    Last Post: 03-30-2010, 01:21 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