Run Time Error 2448

mcgraw

Registered User.
Local time
Today, 11:44
Joined
Nov 13, 2009
Messages
77
I am trying to update a date/time field in a subform, and when I get to the line in the code telling it to set end_date = Now(), I get Run Time Error 2448: You can't assign a value to this object.

Code:
If Me!group_ID = Null Then
    Me!group_ID = Null
    Else
    If Me!group_ID = Forms![Issue Details]![tblWithGroup-datasheet]!ID Then
    .Edit
    [COLOR=red]Forms![Issue Details]![tblWithGroup-datasheet]!End_Date = Now()[/COLOR]
    'Me!group_ID = 999
    
   End If
End If

I triple checked, and subform is set to allow additions, edits and deletions.

How can I get this to put Now() as the end_date in the subform?

Many thanks!
 
Your subform syntax is off. You need to

1. refer to the subform control which is the control on the main form that houses the subform (and not the subform itself unless the name is the same).

2. Use .Form. to tell Access you want a property or method on the subform and not the subform control:

Forms!MainFormNameHere.SubformControlNameHere.Form.ControlOnSubformHere

So, if the subform control name is really:tblWithGroup-datasheet

Then the syntax is:
Forms![Issue Details]![tblWithGroup-datasheet].Form.End_Date = Now()
 
What is written in CONTROL SOURCE properties, (field End_Date)??
 
Bob...you are a VBA GOD! Thanks, that worked like a charm!
 
ok, I just discovered another small problem. For some reason the first part of my code doesn't work...
Code:
If me!group_ID = Null Then
me!group_ID = Null

It isn't recognizing if the field is blank, and just tries to go to the if me!group_ID = [issue details] part, and then gives an error because there isn't anything in that subform for this record yet.

How can I get this to just skip it if the group_ID doesn't have anything in it? (I also tried if group_ID = "", and got the same error...
 
ok, I just discovered another small problem. For some reason the first part of my code doesn't work...
Code:
If me!group_ID = Null Then
me!group_ID = Null

It isn't recognizing if the field is blank, and just tries to go to the if me!group_ID = [issue details] part, and then gives an error because there isn't anything in that subform for this record yet.

How can I get this to just skip it if the group_ID doesn't have anything in it? (I also tried if group_ID = "", and got the same error...

Actually it would be

If IsNull(Me!group_ID) Then

but why would you check to see if it is null and then if it is you assign null to it? That doesn't make sense. If it is null you just leave it alone (UNLESS you mean to check to see if it is NOT null and then make it null if it is, but then the rest of the code wouldn't make sense).
 
If it is null, I do just want to leave it alone, but couldn't figure out how to get it to do nothing...
 
If it is null, I do just want to leave it alone, but couldn't figure out how to get it to do nothing...

Just change it to this:

Code:
If Not IsNull(Me!group_ID) Then
    If Me!group_ID = Forms![Issue Details]![tblWithGroup-datasheet].Form!ID Then
      Forms![Issue Details]![tblWithGroup-datasheet].Form!End_Date = Now()
   End If
End If
 
Again, you are a GOD...and I bow down to your superiorness. Thanks so much for all the help!!!!
 
Again, you are a GOD...and I bow down to your superiorness. Thanks so much for all the help!!!!

Nope, just a lot of years of experience (and I pale in comparison with many others here). :) But thanks anyway.
 

Users who are viewing this thread

Back
Top Bottom