dbTalk Databases Forums  

Data from an open form to a subform in Data sheet view

comp.databases.ms-access comp.databases.ms-access


Discuss Data from an open form to a subform in Data sheet view in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
A_Classic_Man
 
Posts: n/a

Default Data from an open form to a subform in Data sheet view - 02-02-2011 , 04:30 PM






I have a subform "frmActivity" which is in datasheet view on the main
form. Two of the fields on the subform are "Activity" which is a combo
box and "ActivityHours".

When "Leave" is selected in the Activity" field, a form entitled
"frmLeave" opens. This form has a field entitled "LeaveHours".

When I close "frmLeave", I would like the data (a number) from
"LeaveHours" to populate the "ActivityHours" field on the subform
which will correspond with the record inwhich I entered "Leave".

I need help with the code to make this happen. Any suggestions will be
appreciated

Ron

Reply With Quote
  #2  
Old   
Marshall Barton
 
Posts: n/a

Default Re: Data from an open form to a subform in Data sheet view - 02-02-2011 , 07:09 PM






A_Classic_Man wrote:

Quote:
I have a subform "frmActivity" which is in datasheet view on the main
form. Two of the fields on the subform are "Activity" which is a combo
box and "ActivityHours".

When "Leave" is selected in the Activity" field, a form entitled
"frmLeave" opens. This form has a field entitled "LeaveHours".

When I close "frmLeave", I would like the data (a number) from
"LeaveHours" to populate the "ActivityHours" field on the subform
which will correspond with the record inwhich I entered "Leave".

Put code something like this in the combo box's AfterUpdate
event:
DoCmd.OpenForm "frmLeave", WindowMode:=acDialog
Me.ActivityHours = Forms!frmLeave.LeaveHours
DoCmd.Close acForm, "frmLeave", acSaveNo

Now, the trick is that frmLeave must have a command button
that users think closes the form, but the button only make
the form invisible:
Me.Visible = False


--
Marsh

Reply With Quote
  #3  
Old   
A_Classic_Man
 
Posts: n/a

Default Re: Data from an open form to a subform in Data sheet view - 02-06-2011 , 11:17 PM



On Feb 2, 7:09*pm, Marshall Barton <marshbar... (AT) wowway (DOT) com> wrote:
Quote:
A_Classic_Man wrote:
I have a subform "frmActivity" which is in datasheet view on the main
form. Two of the fields on the subform are "Activity" which is a combo
box and "ActivityHours".

When "Leave" is selected in the Activity" field, a form entitled
"frmLeave" opens. This form has a field entitled "LeaveHours".

When I close "frmLeave", I would like the data (a number) from
"LeaveHours" to populate the "ActivityHours" field on the subform
which will correspond with the record inwhich I entered "Leave".

Put code something like this in the combo box's AfterUpdate
event:
* *DoCmd.OpenForm "frmLeave", WindowMode:=acDialog
* *Me.ActivityHours = Forms!frmLeave.LeaveHours
* *DoCmd.Close acForm, "frmLeave", acSaveNo

Now, the trick is that frmLeave must have a command button
that users think closes the form, but the button only make
the form invisible:
* *Me.Visible = False

--
Marsh
Sorry for the long delay in responding. Busy Busy
Thank you for answering

Ron

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.