dbTalk Databases Forums  

Subform won't scroll when new record in mainform becomes dirty.

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


Discuss Subform won't scroll when new record in mainform becomes dirty. in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Greg (codepug@gmail.com)
 
Posts: n/a

Default Subform won't scroll when new record in mainform becomes dirty. - 01-23-2009 , 08:41 PM






I have a mainform and subform that both share the same table. The
mainform displays a single employees sick leave occurrence. The
continuous subform displays all of the employees sick leave
occurrences. The two forms are linked together (child/parent).

All works fine, except when I am creating a new record. Once the new
record in the main form becomes dirty, I cannot scroll through the
subform to check out his previous history. For some reason the subform
seems to freeze or not accept focus from my mouse. I can’t use the
scroll bar etc. On the other hand, in the same circumstance, I can use
a button to bring up the subform, and it works.

Any ideas???
Greg

Reply With Quote
  #2  
Old   
Greg (codepug@gmail.com)
 
Posts: n/a

Default Re: Subform won't scroll when new record in mainform becomes dirty. - 01-24-2009 , 10:15 AM






For some reason my subform control will not accept focus when adding a
New Record in the parent main form.
The main form (single form) has a (continuous form) placed on it. The
main form displays an individual sick leave
occurrence, the subform is linked (parent/child) and displays all sick
leave occurrences for that individual. This works
fine. I need the ability to scroll through the subform to view all
sick leave occurrences for any one individual that is being displayed
on the main form. Again, this works fine. The problem is when a new
record is being created, the subform no longer accepts focus for
scrolling through the individuals past sick leave history. The link
works, since the individuals records do show in the subform window,
but I cannot get focus on the subform to scroll (ie by mouse or code),
therefore I cannot view the individuals history when adding the new
record. This occurs when a new record is created and becomes dirty.

Is this normal behavior? If so, how do I accomplish my goal?
Others have posted this problem, but no viable solution was posted!
A button with a popup of the same subform works, but the same form
embedded does not?

Please, Any Suggestions!
Greg


Reply With Quote
  #3  
Old   
robert.waters
 
Posts: n/a

Default Re: Subform won't scroll when new record in mainform becomes dirty. - 01-24-2009 , 12:11 PM



On Jan 23, 9:41*pm, "Greg (code... (AT) gmail (DOT) com)" <code... (AT) gmail (DOT) com>
wrote:
Quote:
I have a mainform and subform that both share the same table.
So the recordsource for both forms is the table, directly?
Have you tried using queries instead? This way, you can be sure that
each form has a distinct recordset. This may help you additionally by
allowing you to set each form's record locking method and recordset
type (perhaps the main form acquires a lock on the data when it
becomes dirty, causing a problem on the subform).

I am just guessing here, but that's where I would personally start.

HTH



Reply With Quote
  #4  
Old   
Greg (codepug@gmail.com)
 
Posts: n/a

Default Re: Subform won't scroll when new record in mainform becomes dirty. - 01-24-2009 , 12:20 PM



Thanks Robert

Each form has a unique Query for its record source.
Each query references the EmployeeTable and SickListTable.


Greg


Reply With Quote
  #5  
Old   
Salad
 
Posts: n/a

Default Re: Subform won't scroll when new record in mainform becomes dirty. - 01-24-2009 , 01:02 PM



Greg (codepug (AT) gmail (DOT) com) wrote:

Quote:
For some reason my subform control will not accept focus when adding a
New Record in the parent main form.
The main form (single form) has a (continuous form) placed on it. The
main form displays an individual sick leave
occurrence, the subform is linked (parent/child) and displays all sick
leave occurrences for that individual. This works
fine. I need the ability to scroll through the subform to view all
sick leave occurrences for any one individual that is being displayed
on the main form. Again, this works fine. The problem is when a new
record is being created, the subform no longer accepts focus for
scrolling through the individuals past sick leave history. The link
works, since the individuals records do show in the subform window,
but I cannot get focus on the subform to scroll (ie by mouse or code),
therefore I cannot view the individuals history when adding the new
record. This occurs when a new record is created and becomes dirty.

Is this normal behavior? If so, how do I accomplish my goal?
Others have posted this problem, but no viable solution was posted!
A button with a popup of the same subform works, but the same form
embedded does not?

Please, Any Suggestions!
Greg

Perhaps your definition of main/subform are incorrect. How can you link
a new record (parent) to a subform? What's the subform to link to? If
you are adding a new record to the subform, maybe use unbound controls
and then have a save button that write/saves a new sick record and then
requery the subform when saved.

Maybe what you need is a main form (employee) and then two subforms;
subform 1 for the continuous and another for new....or detail.



Reply With Quote
  #6  
Old   
Greg (codepug@gmail.com)
 
Posts: n/a

Default Re: Subform won't scroll when new record in mainform becomes dirty. - 01-24-2009 , 01:29 PM



Thanks for your reply Salad.

My subForm was placed on the Mainform, and its Only Purpose is to
Display sick history.

The subForm control for the subform links Child as EMPLOYEE.EMPID, and
the Master as SICK.EMPID.
This all seems to work OK, until I create a new record. Then I simply
cannot use the scroll bar on the subform.
I believe that I have linked the subform to the mainform. My MainForm
is SICKREC and the subform is used to display the all the sickleave
recs for the employee display on the main form. I really do not even
care if the subform does not display the new/active record, I just
need it to simply display the employees previous sick rec history.
When I add a new record, it is taking place in the MainForm, the
subform is just meant to display past history for the selected
individual.
Again, a button on the form can popup the very same subform during the
new record, and it works (I can scroll). It is just a problem when
imbedded on the form.

Am I working against Access basic principle? Should the subform lose
focus when a new record is being created in the main form?

Thankyou Salad





Quote:
Perhaps your definition of main/subform are incorrect. *How can you link
a new record (parent) to a subform? *What's the subform to link to? *If
you are adding a new record to the subform, maybe use unbound controls
and then have a save button that write/saves a new sick record and then
requery the subform when saved.

Maybe what you need is a main form (employee) and then two subforms;
subform 1 for the continuous and another for new....or detail.- Hide quoted text -

- Show quoted text -


Reply With Quote
  #7  
Old   
Salad
 
Posts: n/a

Default Re: Subform won't scroll when new record in mainform becomes dirty. - 01-24-2009 , 04:46 PM



Greg (codepug (AT) gmail (DOT) com) wrote:

Quote:
Thanks for your reply Salad.

My subForm was placed on the Mainform, and its Only Purpose is to
Display sick history.

The subForm control for the subform links Child as EMPLOYEE.EMPID, and
the Master as SICK.EMPID.
Hmmm...maybe you could have them both link to SICK.EMPID. You might
want to modify your recordsource. I'm unsure of your of your SQL or
recordsource for these forms.

I guess I'm not getting the "layout". Perhaps by envisioning it we'd
get it. Ex:
MainForm
EmpID (combo box)
SickDateStart
SickDateEnd
Sickness
----> link to subform is EmpID and is continuour
SickStart SickEnd Sickness
SickStart SickEnd Sickness
...
SickStart SickEnd Sickness

I would think that if you are at a new record there's nothing to "link"
to. One option to think about is that when you go to another mainform
record see if, in the OnCurrent event, whether or not you are in an
existing or a new record. Then set a filter and blank out the link
master/child values. Then do something like this.
Dim strF As String
Dim lngEmp As Long
If Me.NewRecord then
lngEmp = 0
Else
lngEmp = Me.EmpID
Endif
Me.YourSubFormName.Form.Filter = "EmpID = " & lngEmp
Me.YourSubFormName.Form.FilterOn = True

Then when you add the employeeID to the newrecord, let's say the field
is ComboEmp, in the AfterUpdate event of the combo something like
If Me.NewRecord then
'the next line may not be needed
Me.YourSubFormName.Form.FilterOn = False
Me.YourSubFormName.Form.Filter = "EmpID = " & Me.ComboEMp
Me.YourSubFormName.Form.FilterOn = True
Endif

I don't know your recordsources but when you go to a new record, do
something like
msgbox "My empID is " & empID
and see if it's nothing or if its a value.

Quote:
This all seems to work OK, until I create a new record. Then I simply
cannot use the scroll bar on the subform.
I believe that I have linked the subform to the mainform. My MainForm
is SICKREC and the subform is used to display the all the sickleave
recs for the employee display on the main form. I really do not even
care if the subform does not display the new/active record, I just
need it to simply display the employees previous sick rec history.
When I add a new record, it is taking place in the MainForm, the
subform is just meant to display past history for the selected
individual.
Again, a button on the form can popup the very same subform during the
new record, and it works (I can scroll). It is just a problem when
imbedded on the form.

Am I working against Access basic principle? Should the subform lose
focus when a new record is being created in the main form?

Thankyou Salad






Perhaps your definition of main/subform are incorrect. How can you link
a new record (parent) to a subform? What's the subform to link to? If
you are adding a new record to the subform, maybe use unbound controls
and then have a save button that write/saves a new sick record and then
requery the subform when saved.

Maybe what you need is a main form (employee) and then two subforms;
subform 1 for the continuous and another for new....or detail.- Hide quoted text -

- Show quoted text -



Reply With Quote
  #8  
Old   
robert.waters
 
Posts: n/a

Default Re: Subform won't scroll when new record in mainform becomes dirty. - 01-24-2009 , 05:05 PM



On Jan 24, 2:29*pm, "Greg (code... (AT) gmail (DOT) com)" <code... (AT) gmail (DOT) com>
wrote:
Quote:
Thanks for your reply Salad.

My subForm was placed on the Mainform, and its Only Purpose is to
Display sick history.

The subForm control for the subform links Child as EMPLOYEE.EMPID, and
the Master as SICK.EMPID.
This all seems to work OK, until I create a new record. Then I simply
cannot use the scroll bar on the subform.
I believe that I have linked the subform to the mainform. My MainForm
is SICKREC and the subform is used to display the all the sickleave
recs for the employee display on the main form. I really do not even
care if the subform does not display the new/active record, I just
need it to simply display the employees previous sick rec history.
When I add a new record, it is taking place in the MainForm, the
subform is just meant to display past history for the selected
individual.
Again, a button on the form can popup the very same subform during the
new record, and it works (I can scroll). It is just a problem when
imbedded on the form.

Am I working against Access basic principle? *Should the subform lose
focus when a new record is being created in the main form?

Thankyou Salad

Perhaps your definition of main/subform are incorrect. *How can you link
a new record (parent) to a subform? *What's the subform to link to? *If
you are adding a new record to the subform, maybe use unbound controls
and then have a save button that write/saves a new sick record and then
requery the subform when saved.

Maybe what you need is a main form (employee) and then two subforms;
subform 1 for the continuous and another for new....or detail.- Hide quoted text -

- Show quoted text -
I think Salad may have a point with disconnecting the parent form from
the subform (i.e. not using Link Master/Child); obviously, something
is going wrong there.
In the parent Form's Dirty event (or Current), you could update the
subform directly, with the new ID (Me.subform.id=me.id ;
Me.subform.requery, or Me.subform,recordsource=...).
Just a thought.
This is not technically "The Access Way (tm)" of course.


Reply With Quote
  #9  
Old   
robert.waters
 
Posts: n/a

Default Re: Subform won't scroll when new record in mainform becomes dirty. - 01-24-2009 , 05:15 PM



On Jan 24, 2:29*pm, "Greg (code... (AT) gmail (DOT) com)" <code... (AT) gmail (DOT) com>
wrote:
Quote:
Thanks for your reply Salad.

My subForm was placed on the Mainform, and its Only Purpose is to
Display sick history.

The subForm control for the subform links Child as EMPLOYEE.EMPID, and
the Master as SICK.EMPID.

Why don't you use sick.empid as both master and child? (or the other
way around)


Reply With Quote
  #10  
Old   
Bob Quintal
 
Posts: n/a

Default Re: Subform won't scroll when new record in mainform becomes dirty. - 01-24-2009 , 05:22 PM



"Greg (codepug (AT) gmail (DOT) com)" <codepug (AT) gmail (DOT) com> wrote in
news:f6a9f8c3-202e-4707-bd38-ffc21d2d5890
@y1g2000pra.googlegroups.com
:

Quote:
Thanks for your reply Salad.

My subForm was placed on the Mainform, and its Only Purpose is to
Display sick history.
+

If it's a display only tool, why not use a listbox?


Quote:
Am I working against Access basic principle? Should the subform
lose focus when a new record is being created in the main form?

Yes, one principle in Access is that when a new record is dirtied,
Access does what is necessary to prevent the user from adding new
records to the subform, because it cannot pass the linking parent
field, since it's not saved yet. It actually locks every bit of
functionality on the subform, not just the scroll bar.

Q



Quote:
Thankyou Salad





Perhaps your definition of main/subform are incorrect. *How can
you lin
k
a new record (parent) to a subform? *What's the subform to link
to? *
If
you are adding a new record to the subform, maybe use unbound
controls and then have a save button that write/saves a new sick
record and then requery the subform when saved.

Maybe what you need is a main form (employee) and then two
subforms; subform 1 for the continuous and another for new....or
detail.- Hide quot
ed text -

- Show quoted text -



--
Bob Quintal

PA is y I've altered my email address.


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.