you don't need to move focus to the subform to set the value of a field in
that subform's RecordSource. you just need to use the correct references to
the "target" field in your VBA code.
the following code example uses these parameters: the main form is called
frmMain. the review subform is called ChildReview. the date subform is
called ChildDate (if you really named the subform control "Date", recommend
you change it, since Date is a reserved word in Access). the field in the
ChildDate subform is called ReviewDate. the code below runs from within the
ChildReview subform's code module, as
Me.Parent!ChildDate.Form!ReviewDate = Now
you'll have to substitute the correct name of the date subform, and the
correct name of the review date field, of course. and note that you do not
include parentheses when you use the Now function in VBA.
hth
> Hello Everybody
> I have looked for existing thread on this one but could not find my answer.
[quoted text clipped - 22 lines]
>
> Thanks
vdha - 30 Apr 2006 18:12 GMT
Thanks Tina but I could not get it to work
Here is what I tried
Me!EditSalesOrder!Scorecard!POMortemDate = Now
Me!Parent!Scorecard!POMortemDate = Now
These are the real name I gave my subforms. I was just maknig it easier for
you
Thanks
>you don't need to move focus to the subform to set the value of a field in
>that subform's RecordSource. you just need to use the correct references to
[quoted text clipped - 20 lines]
>>
>> Thanks
tina - 30 Apr 2006 18:24 GMT
go back and look at the syntax i posted, and try using it *exactly as i
posted it*, with the correct subform and field names substituted. and, of
course, you can use Date instead of Now.
hth
> Thanks Tina but I could not get it to work
>
[quoted text clipped - 30 lines]
> >>
> >> Thanks
>Hello Everybody
>I have looked for existing thread on this one but could not find my answer.
[quoted text clipped - 3 lines]
>In the review form I have a button that will send a report but I need to
>stamp the date when it was done and all my dates are in the "Date" subform.
Just to clarify: They're not "in" the Date subform. They're stored in
some record or records of some table. The Subform is just a *window*
which can display that record (perhaps among many other records); the
form itself is not a data storage repository.
>SO I need a VB code within the SendReport_OnCLick to go from the review form
>to the date form and then do
>reviewdate = now()
I would suggest two things:
1. That you might do better to open a Recordset based on the table,
and edit the table field in that way - rather than trying to update
the Form directly.
2. Quite likely the ReviewDate field should not exist AT ALL, if its
value is redundant with a date stored in the Dates table.
>I tried
>
>Forms. Main.Date.SetFocus (That works)
>Me!ReviewDate = Now() (That doesn't work)
>Forms. Main.Review.SetFocus
If you must do this, try
Forms!Main![Date].Form![ReviewDate] = Now()
Do note that Date is a reserved word - for the current date function
Date() - and as such is a bad choice as a name for an object; and that
Now() does *NOT* return today's date, it returns the current date and
time accurate to microseconds. If you search a field defined using
Now() for a date value such as 4/29/2006, it will return no records
unless the record was entered precisely at midnight.
John W. Vinson[MVP]
vdha - 30 Apr 2006 18:13 GMT
Thanks
I don't use the word date, I was just trying to make it easier to follow.
But I didn't that Date could be used.
Thanks
>>Hello Everybody
>>I have looked for existing thread on this one but could not find my answer.
[quoted text clipped - 38 lines]
>
> John W. Vinson[MVP]
vdha - 30 Apr 2006 18:35 GMT
Thanks Both of you,
I finally used the recordset and got it to work.
Great. Thanks again for this quick help
>Thanks
>I don't use the word date, I was just trying to make it easier to follow.
[quoted text clipped - 6 lines]
>>
>> John W. Vinson[MVP]