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  

Add record Problems



 
 
Thread Tools Display Modes
  #11  
Old January 20th, 2006, 07:41 PM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.formsprogramming
external usenet poster
 
Posts: n/a
Default Add record Problems

Thanks Steve,

I tend to agree with you. What I finally wound up doing was this (and
you will probably laugh):

I recreated the form from scratch. Using just basic access functionality
and not worying about trying to make the form do double duty. I'll
create a separate admin form and menu button to handle that. It is much
cleaner and works like a charm.

Now if I could just figure out this damn running total isse I'm having.

I need to create a daily running total of hours from the subform on the
main form. So far so good. I use the Dsum and it updates the hours
correctly. But only after I close the form. I'm trying to put a requery
for the running totals fields someplace in the subform so it performs a
requery after the hours are entered. I can get that part too but the
problem is it then prevents me from adding records to the subform (which
is in Datasheet view).
The fields on the subform are in this order
ResourceID, WeekID (both Hidden)
Date, ProjectID, PhaseID, Hours and Comments.

I've tried the following events with no luck Hours_afterUpdate event,
Comments_exit, Form Current (logically where it should be but it
prevents me adding new lines/records to the subform), Date_beforeupdate,
Date_enter, Date_Exit and a few others.

Any ideas what event I should put the requery into?

Thanks again for your help.

In article ,
says...
Craig,

Thanks for the further clarification.

Here's the rub... If you open the form from the Main Menu form, you
either want it at an existing record, or you want it at a new record.
If you have ResourceID and WeekID as a composite primary key, then a
specified record involves defining both of these. At the moment your
code opens the form at a record specified by the ResourceID, of which
the database actually contains a number, so it opens at whatever happens
to be the first one in the recordset. And then it tries to delete the
WeekID entry for this record. Nope, this is not what you want.

So, here's how I would see it at the moment. If you want the form
opened at a new record for data entry, you would use this code from the
main menu...
Private Sub cmdTimeEntry_Click()
DoCmd.OpenForm "frmTimeEntry", , , , acFormAdd
End Sub

If you want the ResourceID for the new record to be defaulted to the
value of the ResourceID specified on the Main Menu, like this...
Private Sub cmdTimeEntry_Click()
DoCmd.OpenForm "frmTimeEntry", , , , acFormAdd
Forms!frmTimeEntry!cboResourceID = Me.ResourceID
End Sub

If you want the form to open at a new record, but still be able to
scroll back to see previous records, like this...
Private Sub cmdTimeEntry_Click()
DoCmd.OpenForm "frmTimeEntry"
DoCmd.GoToRecord , , acNewRec
Forms!frmTimeEntry!cboResourceID = Me.ResourceID
End Sub

If you want the above, but only to scroll back to existing records for
the specified ResourceID...
Private Sub cmdTimeEntry_Click()
DoCmd.OpenForm "frmTimeEntry", , , "[ResourceID]=" & Me.ResourceID
DoCmd.GoToRecord , , acNewRec
Forms!frmTimeEntry!cboResourceID = Me.ResourceID
End Sub

If you want to open the form to show existing records for the specified
ResourceID...
Private Sub cmdTimeEntry_Click()
DoCmd.OpenForm "frmTimeEntry", , , "[ResourceID]=" & Me.ResourceID
End Sub

If you want to open the form to show a single existing specified record...


--
You have no right to protection against being offended.
  #12  
Old January 20th, 2006, 09:27 PM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.formsprogramming
external usenet poster
 
Posts: n/a
Default Add record Problems

Craig,

I would imagine the After Update event of the subform would be the way
to go. And you need Recalc not Requery. Since the control you want to
update the display of is on the main form, I guess it would be...
Me.Parent.Recalc

By the way, as an aside, 'date' is a Reserved Word (i.e. has a special
meaning) in Acces, and as such should not be used as the name of a field
or control.

--
Steve Schapel, Microsoft Access MVP


Craig M. Bobchin wrote:
Thanks Steve,

I tend to agree with you. What I finally wound up doing was this (and
you will probably laugh):

I recreated the form from scratch. Using just basic access functionality
and not worying about trying to make the form do double duty. I'll
create a separate admin form and menu button to handle that. It is much
cleaner and works like a charm.

Now if I could just figure out this damn running total isse I'm having.

I need to create a daily running total of hours from the subform on the
main form. So far so good. I use the Dsum and it updates the hours
correctly. But only after I close the form. I'm trying to put a requery
for the running totals fields someplace in the subform so it performs a
requery after the hours are entered. I can get that part too but the
problem is it then prevents me from adding records to the subform (which
is in Datasheet view).
The fields on the subform are in this order
ResourceID, WeekID (both Hidden)
Date, ProjectID, PhaseID, Hours and Comments.

I've tried the following events with no luck Hours_afterUpdate event,
Comments_exit, Form Current (logically where it should be but it
prevents me adding new lines/records to the subform), Date_beforeupdate,
Date_enter, Date_Exit and a few others.

Any ideas what event I should put the requery into?

  #13  
Old January 20th, 2006, 10:46 PM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.formsprogramming
external usenet poster
 
Posts: n/a
Default Add record Problems

Steve,

Thanks, The recalc worked, but with one strange side effect.... When
leaving the last column on the subform, instead of adding a new
line/record it jumps back to the 1st line/record in the subform data
sheet. I had to add a DoCmd.GoToRecord , , acNewRec after the recalc to
get it to work, but all is fine now. Thanks again for all your help.

In article ,
says...
Craig,

I would imagine the After Update event of the subform would be the way
to go. And you need Recalc not Requery. Since the control you want to
update the display of is on the main form, I guess it would be...
Me.Parent.Recalc

By the way, as an aside, 'date' is a Reserved Word (i.e. has a special
meaning) in Acces, and as such should not be used as the name of a field
or control.



--
You have no right to protection against being offended.
  #14  
Old January 20th, 2006, 11:35 PM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.formsprogramming
external usenet poster
 
Posts: n/a
Default Add record Problems

Craig,

You haven't still got a Requery code in there, have you, on the
subform's After Update event, or the After Update or Exit or some such
event of the last control on the subform?

--
Steve Schapel, Microsoft Access MVP


Craig M. Bobchin wrote:
Steve,

Thanks, The recalc worked, but with one strange side effect.... When
leaving the last column on the subform, instead of adding a new
line/record it jumps back to the 1st line/record in the subform data
sheet. I had to add a DoCmd.GoToRecord , , acNewRec after the recalc to
get it to work, but all is fine now. Thanks again for all your help.

  #15  
Old January 21st, 2006, 01:27 AM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.formsprogramming
external usenet poster
 
Posts: n/a
Default Add record Problems

Nope, the only code on the subform is the following: And yes I do know I
have to change the Date field's name

Option Compare Database
Option Explicit

Private Sub Date_BeforeUpdate(Cancel As Integer)
'if the user enters a date that is more than 7 days less that the
weekending date
'display an error and set the focus back
'to the date field.

Dim intDays As Integer
Dim dtDateEntered As Date
Dim dtWeekEnding As Date

dtDateEntered = Me.Date
dtWeekEnding = Forms!tbltimetrack!txtWeekEnding

If dtDateEntered = dtWeekEnding Then
intDays = DateDiff("d", dtDateEntered, dtWeekEnding)
If intDays 6 Then
MsgBox "The date is not valid. Please re-enter a valid date for
the week-ending: " & dtWeekEnding
Cancel = True
End If
Else
MsgBox "Date is not Valid."
Cancel = True
End If

End Sub


Private Sub Form_AfterUpdate()
Me.Parent.Recalc
DoCmd.GoToRecord , , acNewRec
End Sub



In article ,
says...
Craig,

You haven't still got a Requery code in there, have you, on the
subform's After Update event, or the After Update or Exit or some such
event of the last control on the subform?



--
You have no right to protection against being offended.
  #16  
Old January 21st, 2006, 01:56 AM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.formsprogramming
external usenet poster
 
Posts: n/a
Default Add record Problems

Craig,

Ok, well I wouldn't have expected that behaviour with the subfrom, but
anyway, you've got it sorted so no point in sweating over that one! :-)

Best wishes for the rest of the project.

--
Steve Schapel, Microsoft Access MVP


Craig M. Bobchin wrote:
Nope, the only code on the subform is the following: And yes I do know I
have to change the Date field's name

 




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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a New Record in Sub Form_Current Peter Hallett Using Forms 6 January 27th, 2006 03:03 PM
Last (blank) record on form will not delete! [email protected] General Discussion 2 December 16th, 2005 06:16 PM
Creating Records in tables automatically peterg290935 Using Forms 8 June 22nd, 2005 08:12 AM
strategy for data entry in multiple tables LAF Using Forms 18 April 25th, 2005 04:04 AM
Problems Deleting a record. Kris L. Using Forms 1 July 15th, 2004 03:06 AM


All times are GMT +1. The time now is 04:46 PM.


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