A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Saving a record in subform



 
 
Thread Tools Display Modes
  #1  
Old December 7th, 2009, 04:24 PM posted to microsoft.public.access.forms
hotplate
external usenet poster
 
Posts: 55
Default Saving a record in subform

Hi,

I need to save a record in a subform before trying to close the main
form.

I tried creating a save command in the subform and calling it when
trying to close the main form. Unfortunately I could not figure out
how to do this.

The reason I need to save subform record is because I am adding the
numbers in the subform to see if they equal a number in the main
record, if they don't match the form will not close. I can't even
check for a match if the subform record does not get saved before
closing.

I am using a command button to close the main form.

Thanks
  #2  
Old December 8th, 2009, 07:28 AM posted to microsoft.public.access.forms
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default Saving a record in subform

Do both forms have a table or query as their record source?
Are you using the link master and link child fields?

If you are using bound forms, does your save button have code like this?
If Me.Dirty = True Then
Me.Dirty = False
End If


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

"hotplate" wrote in message
...
Hi,

I need to save a record in a subform before trying to close the main
form.

I tried creating a save command in the subform and calling it when
trying to close the main form. Unfortunately I could not figure out
how to do this.

The reason I need to save subform record is because I am adding the
numbers in the subform to see if they equal a number in the main
record, if they don't match the form will not close. I can't even
check for a match if the subform record does not get saved before
closing.

I am using a command button to close the main form.

Thanks



  #3  
Old December 8th, 2009, 03:16 PM posted to microsoft.public.access.forms
hotplate
external usenet poster
 
Posts: 55
Default Saving a record in subform

Yes both forms have a table as their record source and they are
linked.

I am using the wizard provided save command, so no I don't have that
code.

I am not sure where this is going.

On Dec 8, 2:28*am, "Jeanette Cunningham"
wrote:
Do both forms have a table or query as their record source?
Are you using the link master and link child fields?

If you are using bound forms, does your save button have code like this?
If Me.Dirty = True Then
* * Me.Dirty = False
End If

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

"hotplate" wrote in message

...

Hi,


I need to save a record in a subform before trying to close the main
form.





I tried creating a save command in the subform and calling it when
trying to close the main form. *Unfortunately I could not figure out
how to do this.


The reason I need to save subform record is because I am adding the
numbers in the subform to see if they equal a number in the main
record, if they don't match the form will not close. *I can't even
check for a match if the subform record does not get saved before
closing.


I am using a command button to close the main form.


Thanks


  #4  
Old December 8th, 2009, 07:32 PM posted to microsoft.public.access.forms
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default Saving a record in subform

Thanks for providing the info.
When you are using bound forms and main form and subform are linked using
the link master and link child fields, access does save the subform record
when user clicks out of the subform onto the main form.

I sugest that you remove the save button from the subform - as access will
automatically save the subform data when user clicks something on the main
form.

Put an unbound textbox on the subform and set its control source to
=Sum([FieldName])

To check for a match when on the main form, you can use code like this--
Private Function CheckForMatch() As Boolean
If Me.[NameOfControl] = Me.[SubformControlName].Form.[NameOf
TheUnboundTextBox] Then
CheckForMatch = True
Else
CheckForMatch = False
End If
End Function

Then on the unload event for the main form, you can go
If Not CheckForMatch = True Then
Cancel = True
End If

The above should prevent the main form closing unless the numbers match.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


"hotplate" wrote in message
...
Yes both forms have a table as their record source and they are
linked.

I am using the wizard provided save command, so no I don't have that
code.

I am not sure where this is going.

On Dec 8, 2:28 am, "Jeanette Cunningham"
wrote:
Do both forms have a table or query as their record source?
Are you using the link master and link child fields?

If you are using bound forms, does your save button have code like this?
If Me.Dirty = True Then
Me.Dirty = False
End If

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

"hotplate" wrote in message

...

Hi,


I need to save a record in a subform before trying to close the main
form.





I tried creating a save command in the subform and calling it when
trying to close the main form. Unfortunately I could not figure out
how to do this.


The reason I need to save subform record is because I am adding the
numbers in the subform to see if they equal a number in the main
record, if they don't match the form will not close. I can't even
check for a match if the subform record does not get saved before
closing.


I am using a command button to close the main form.


Thanks



  #5  
Old December 11th, 2009, 12:40 PM posted to microsoft.public.access.forms
hotplate
external usenet poster
 
Posts: 55
Default Saving a record in subform

I had code very similar to this checking for a match (your code is
better though).

My problem is that if they enter the number in the control of the
subform and try to close the form without first exiting that control,
the sum does not update before trying to close. This would only be a
problem if the control in the subform is the very last control the
user enters a value.



On Dec 8, 2:32*pm, "Jeanette Cunningham"
wrote:
Thanks for providing the info.
When you are using bound forms and main form and subform are linked using
the link master and link child fields, access does save the subform record
when user clicks out of the subform onto the main form.

I sugest that you remove the save button from the subform - as access will
automatically save the subform data when user clicks something on the main
form.

Put an unbound textbox on the subform and set its control source to
=Sum([FieldName])

To check for a match when on the main form, you can use code like this--
Private Function CheckForMatch() As Boolean
If Me.[NameOfControl] = Me.[SubformControlName].Form.[NameOf
TheUnboundTextBox] Then
* * CheckForMatch = True
Else
* * CheckForMatch = False
End If
End Function

Then on the unload event for the main form, you can go
If Not CheckForMatch = True Then
* * Cancel = True
End If

The above should prevent the main form closing unless the numbers match.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

"hotplate" wrote in message

...
Yes both forms have a table as their record source and they are
linked.

I am using the wizard provided save command, so no I don't have that
code.

I am not sure where this is going.

On Dec 8, 2:28 am, "Jeanette Cunningham"

wrote:
Do both forms have a table or query as their record source?
Are you using the link master and link child fields?


If you are using bound forms, does your save button have code like this?
If Me.Dirty = True Then
Me.Dirty = False
End If


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


"hotplate" wrote in message


....


Hi,


I need to save a record in a subform before trying to close the main
form.


I tried creating a save command in the subform and calling it when
trying to close the main form. Unfortunately I could not figure out
how to do this.


The reason I need to save subform record is because I am adding the
numbers in the subform to see if they equal a number in the main
record, if they don't match the form will not close. I can't even
check for a match if the subform record does not get saved before
closing.


I am using a command button to close the main form.


Thanks


  #6  
Old December 12th, 2009, 10:04 AM posted to microsoft.public.access.forms
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default Saving a record in subform

You can also use recalc like this--
Me.Recalc
You could try using recalc on the subform in its after update event.
Access gives a lower priority to doing sums than running much of the form's
code.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

"hotplate" wrote in message
...
I had code very similar to this checking for a match (your code is
better though).

My problem is that if they enter the number in the control of the
subform and try to close the form without first exiting that control,
the sum does not update before trying to close. This would only be a
problem if the control in the subform is the very last control the
user enters a value.



On Dec 8, 2:32 pm, "Jeanette Cunningham"
wrote:
Thanks for providing the info.
When you are using bound forms and main form and subform are linked using
the link master and link child fields, access does save the subform record
when user clicks out of the subform onto the main form.

I sugest that you remove the save button from the subform - as access will
automatically save the subform data when user clicks something on the main
form.

Put an unbound textbox on the subform and set its control source to
=Sum([FieldName])

To check for a match when on the main form, you can use code like this--
Private Function CheckForMatch() As Boolean
If Me.[NameOfControl] = Me.[SubformControlName].Form.[NameOf
TheUnboundTextBox] Then
CheckForMatch = True
Else
CheckForMatch = False
End If
End Function

Then on the unload event for the main form, you can go
If Not CheckForMatch = True Then
Cancel = True
End If

The above should prevent the main form closing unless the numbers match.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

"hotplate" wrote in message

...
Yes both forms have a table as their record source and they are
linked.

I am using the wizard provided save command, so no I don't have that
code.

I am not sure where this is going.

On Dec 8, 2:28 am, "Jeanette Cunningham"

wrote:
Do both forms have a table or query as their record source?
Are you using the link master and link child fields?


If you are using bound forms, does your save button have code like this?
If Me.Dirty = True Then
Me.Dirty = False
End If


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


"hotplate" wrote in message


...


Hi,


I need to save a record in a subform before trying to close the main
form.


I tried creating a save command in the subform and calling it when
trying to close the main form. Unfortunately I could not figure out
how to do this.


The reason I need to save subform record is because I am adding the
numbers in the subform to see if they equal a number in the main
record, if they don't match the form will not close. I can't even
check for a match if the subform record does not get saved before
closing.


I am using a command button to close the main form.


Thanks



 




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 Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:48 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.