"Error 2448.... Unable to assign a value to this object."

Solved
lecrol Posted messages 224 Registration date   Status Member Last intervention   -  
f894009 Posted messages 17417 Registration date   Status Member Last intervention   -
Hello,

I saw on the forum that this message was often mentioned. But I couldn't find my answer in all that I read.

From a very simple table, I want to print a report.
In the table, I have numeric fields that are often zero
On the report, I want this zero to be replaced by a blank (in text boxes), so that the report column is not filled with zeros

My code is very simple:

If [Km] > 0 Then
Tot_km = Tot_km + Km
ElseIf Km = 0 Then
Me![LKm].Value = " " it's on this 4th line that Access refuses to obey me (lol)
End If

The same problem for 3 other fields in the table that I would also like to print blank when they are 0 in the table.

A big thank you for your insights. I have the database and its code available for anyone who wants it. It's very small!

Roland

Configuration: Windows 7 / Chrome 30.0.1599.101

8 answers

  1. f894009 Posted messages 17417 Registration date   Status Member Last intervention   1 717
     
    Hello,

    to make your file available, click on the link below

    https://www.cjoint.com/

    Don't forget to copy/paste the created link in your next message.
    0
  2. lecrol Posted messages 224 Registration date   Status Member Last intervention   24
     
    Hello,

    Thank you and congratulations on the quick response!

    Here is the link to the relevant database.
    There is only one table and one report, and you will easily find my "little ones."
    If I’m not being too much of a bother, but you would have noticed, I don’t know how to properly manage my totals at the bottom of the page and at the end of the report.

    Thanks again for the helping hand

    Warm regards,
    Roland

    https://www.cjoint.com/?0JwqT5QE6KN
    0
  3. lecrol Posted messages 224 Registration date   Status Member Last intervention   24
     
    Hello

    I haven't received a response to my request.

    Regarding F894009, did you receive my file sent on October 22?

    Please let me know what you think.

    Best regards,
    Roland
    0
  4. f894009 Posted messages 17417 Registration date   Status Member Last intervention   1 717
     
    Hello,

    I had started looking at your file and then forgot about it. I'm seeing it today.

    Talk to you later!
    0
  5. f894009 Posted messages 17417 Registration date   Status Member Last intervention   1 717
     
    Hello,

    if Access 2000 and above:

    there are two possible solutions, one with Conditional Formatting for the LKM and Photos fields or through VBA. In both cases, the text color is White instead of Black (in your case) (you cannot modify the field value)

    if before 2000:

    one solution through VBA

    It's up to you to choose.
    0
  6. lecrol Posted messages 224 Registration date   Status Member Last intervention   24
     
    Thank you for the quick response.
    I'm not an expert at all in VBA and, above all, this is the very first time I'm creating an editable report.

    Here, I don’t want to change the color! I want to edit the kilometers and the number of photos but not print anything (that is to say "") when these fields are zero in the table.

    I would also like to total them at the bottom of the page and the report. But then, I'm completely lost! I don’t know whether to put it in the format event or in the print event.
    And as a result, my totals are not printing!

    Can you lend a hand, please? A big thank you in advance.
    Best regards
    Roland
    0
  7. f894009 Posted messages 17417 Registration date   Status Member Last intervention   1 717
     
    Re,

    photos but without printing anything (that is to say "") when these fields are zero in the table it seems to me that this is not possible as I wrote to you previously starting from a table. I will check again. For the totals, I will take a look

    A+
    0
  8. f894009 Posted messages 17417 Registration date   Status Member Last intervention   1 717
     
    Re,

    For the zeros, a simple solution: for numeric fields, do not set zero as the default value (see modification when creating the table) and for input in F_tout_article, do not enter zero when there is nothing.

    I will look into the totals.
    0