Form/SubForm-New Record

lsteffen

New member
Local time
Today, 11:36
Joined
Sep 6, 2007
Messages
9
I have a form with an embedded subform for data entry. When the information is put into the form and the user presses enter, the data should then jump down to the subform with the form being blank again ready for another entry. What is happening now, is after the date is entered in the form, it passes that info w/ defaults to the subform and then when all the info is in the form and I press enter, it does not move the data to the subform, it closes the form. Can someone please help?

Thank you,
Liz:confused:
 
There are so many different configurations for Form and SubForm combinations it would be difficult to say without looking a the database.
 
Thank you for your response CyberLynx. I have compacted my db and then zipped it. Here it is attached. It is the frmMechDailyWork and the corresponding frmMechDailyWork(subform) that is not working properly. The matching frmDailyWork and frmDailyWork(subform) are what I was modeling the Mech ones from.

Thank you,
Liz
 

Attachments

Hi Liz

If you want the frmMechDailyWork Form to function in the same fashion as the frmDailyWork Form then all you need to do is add this line of code to the LostFocus event of the Est. Hours Text Box. Set the Lost Focus event property to [Event Procedure] then open the VB IDE (VB editor) with the small button on the far right end of the property box and enter this line of code:

DoCmd.Requery ("qryMechDailyWork_Sub subform")


To automatically place todays date into the Date Scheduled Text Box, you will need to paste this into the Default Value property for the Date Scheduled Text Box:

=Date()

Now, in your first post, you mentioned that you would like to see the data entered in the Main Form to be dropped into the SubForm when the ENTER Key is pressed. I personally call this Hot Loading the SubForm.

In reality, with the way the Controls on Form are currently configured, by pressing the ENTER key is basically the same thing as hitting the TAB key. Focus is moved from one Control to the Next depending upon the Form's current Tab Order.

We can't just Hot Load a SubForm based on a hit from the ENTER key since we may perhaps one day have a TextBox which will have it's Enter Key Behavior property set to New Line In Field instead of Default. To cover all the bases we need to create a small Function to carry out the task and place the cal to that Function directly into either the AfterUpdate or LostFocus property box. Like this:

=UpdateSubForm()

Place this function into the Form's Code Module:

Code:
Private Function UpdateSubForm()
   [COLOR="DarkGreen"]'Prevent MS-Access Screen Updates (helps stop flicker).[/COLOR]
   Application.Echo False
   [COLOR="DarkGreen"]'Refresh the Form. Doing will also update the SubForm
   'since it is linked to the Main Form.[/COLOR]
   Me.Refresh
   [COLOR="DarkGreen"]'Turn Screen updates back on again.[/COLOR]
   Application.Echo True
End Function

Now just paste =UpdateSubForm() into the property box for either the AfterUpdate or LostFocus events.

Done deal....

.
 

Attachments

Last edited:

Users who are viewing this thread

Back
Top Bottom