Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / April 2006

Tip: Looking for answers? Try searching our database.

Change field of a subfrom while in another subform

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
vdha - 30 Apr 2006 04:31 GMT
Hello Everybody
I have looked for existing thread on this one but could not find my answer.
Here is my problem

I have a main form and several subforms. One is Review and the other is Date
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.

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 tried

Forms. Main.Date.SetFocus              (That works)
Me!ReviewDate = Now()                      (That doesn't work)
Forms. Main.Review.SetFocus

But it doesn't recognize the ReviewDate
I can do this kind of thing if I am within the same form but I have never
been able to perform oprations across different subform.
One more thing, all my subform are based on queries in which I call a common
value on the main form .(don't know if that makes a difference)
Let me know if there is a way.

Thanks
tina - 30 Apr 2006 05:42 GMT
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
John Vinson - 30 Apr 2006 05:53 GMT
>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]
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.