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
  #21  
Old   
Greg (codepug@gmail.com)
 
Posts: n/a

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






Tina, this is the culprit! I'm using this code to keep the user in
the
new record (condition "1"), and forcing use of (Undo/Save/Quit)
buttons.



Private Sub Form_BeforeUpdate(Cancel As Integer)
'stay on new record until save or quit
If (Me.OpenArgs = "1") And (Not (blnDone)) Then
Cancel = True
End If
If (Me.OpenArgs = "3") And (Me.Dirty) Then
If Not blnDone Then
MsgBox "Please (Undo) (Save) or (Quit)", vbExclamation,
"Not Complete"
Cancel = True
End If
End If
End Sub

Reply With Quote
  #22  
Old   
tina
 
Posts: n/a

Default Re: Subform won't scroll when new record in mainform becomes dirty. - 01-26-2009 , 09:18 AM






comments inline.

<codepug (AT) gmail (DOT) com> wrote

Quote:
Tina

the only thing that happened was that the unfinished mainform record was
saved to the table. that's a normal occurrence, and there's no way to
change
that behavior in a bound mainform, AFAIK. if you have code running in
the
mainform's BeforeUpdate event to check for missing data, or if there are
any
fields in the underlying table set to Required, then the system is going
to
demand that you either enter the data so the new record can save - or
undo
(Esc) the new record - before entering the subform.

This apparently is my problem. The new record, due to (Required &
Validation checks) during data entry,
is not being committed to the table when I attempt to scroll the
subform.
well, scrolling the subform records requires that you *enter* the subform,
and you can't enter the subform until the record saves to the table.

Quote:
So, I guess Access is locking up
the scroll effort, even though there is no intention to modifiy any
data in the subform. I would think that since
the data was not saved to the table, that there should be no reason to
lockup the subform for viewing.
first of all, you're modifying data in the *table*, and your subform is
bound to that table. but that's really beside the point. subforms are a GUI
feature of Access that were designed for a specific purpose: to make it
easy to add/edit records in a parent table, and then add/edit related
records in a related child table. and in that context, the fact that a
parent record is *automatically* saved before the subform receives the
focus, makes perfect sense and is a valuable safeguard helping to ensure
relational integrity. the fact that subforms can be utilized for
unconventional situations is a side benefit of the flexibility of Access -
but as developers we can't expect optimal performance in these situations.

Quote:
Interestingly,
it does work if I use a button to popup the same subform, while
entering data in the new record.
here's where you're making a common mistake. a form is a form. it behaves as
a subform when it is set as the SourceObject of a subform control within
another form. if you open a form as a popup, it's just a form - it's not a
subform object and there's absolutely no reason to expect it to be governed
by any of the behaviors that are specific to subform objects within mainform
objects.

Quote:
Thank you so much for the excellent tips.
you're very welcome.

Quote:
I had no idea, that I could tie the LinkMasterField to a textbox. I
had the impression
that it had to tie to a table field directly.
yes, very handy, that. if you read up on the
LinkChildFields/LinkMasterFields properties in Help, you'll find that you
can actually set the LinkMasterFields property to a textbox, a combobox,
even to an expression - anything that returns a valid key value, with the
proper DataType, that will match key values in the subform's RecordSource.
you can actually set the LinkChildFields property to an expression, *but not
directly*; instead, you have to use a query as the subform's RecordSource,
and include the expression as a calculated field in the query.

Quote:
Greg



Reply With Quote
  #23  
Old   
tina
 
Posts: n/a

Default Re: Subform won't scroll when new record in mainform becomes dirty. - 01-26-2009 , 09:23 AM



there you go. you'll have to decide which is more important to your process
flow - that only complete records be written to the table, or that the user
be able to review multiple subform records in the middle of entering a new
record. if both are important, then it might be a better option for your
users to provide them with a pop-up form instead of a subform, to display
historical attendance records. or use a listbox (you didn't answer my
earlier question in this thread, regarding what problems you encountered in
using a query with calculated fields as the RowSource of a listbox control).

hth


<codepug (AT) gmail (DOT) com> wrote

Quote:
Tina, this is the culprit! I'm using this code to keep the user in
the
new record (condition "1"), and forcing use of (Undo/Save/Quit)
buttons.



Private Sub Form_BeforeUpdate(Cancel As Integer)
'stay on new record until save or quit
If (Me.OpenArgs = "1") And (Not (blnDone)) Then
Cancel = True
End If
If (Me.OpenArgs = "3") And (Me.Dirty) Then
If Not blnDone Then
MsgBox "Please (Undo) (Save) or (Quit)", vbExclamation,
"Not Complete"
Cancel = True
End If
End If
End Sub



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

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



Tina

Thank you for the incredible tips and insight. I enjoyed every minute
of it!
I should probably spend more time in the books firming up the
fundamentals, but
I more frequently find myself freelancing and blindly exploring and
experimenting to my hearts content.

Quote:
use a listbox (you didn't answer my earlier question in this thread, regarding what problems >>you encountered in using a query with calculated fields as the RowSource of a listbox control).
I’m working another aspect of my project now, and have discovered that
calculated fields and conditional formatting can quickly overburden a
continuous form, and result in screen flashing, and looping struggles.
So, I discovered that an SQL Query can substitute and eliminate some
of these problems. Now I struggle with attempting to reference a
textbox in the row with my SQL query (not doing well with that), and
additional problems with getting a user defined function that performs
many calculations based on public variables to somehow fit in, and I’m
not doing to well with that either.

It’s probably time for the book.

Thanks Again
Greg


Reply With Quote
  #25  
Old   
tina
 
Posts: n/a

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



you're very welcome, Greg. i enjoyed it too - subforms are near and dear to
my heart because they're so useful and so handy, and i work with them quite
a lot in my user interfaces. but i don't often see threads discussing
non-standard subform setups, so it was fun to dig into it. good luck with
your project!


<codepug (AT) gmail (DOT) com> wrote

Tina

Thank you for the incredible tips and insight. I enjoyed every minute
of it!
I should probably spend more time in the books firming up the
fundamentals, but
I more frequently find myself freelancing and blindly exploring and
experimenting to my hearts content.

Quote:
use a listbox (you didn't answer my earlier question in this thread,
regarding what problems >>you encountered in using a query with calculated
fields as the RowSource of a listbox control).

I’m working another aspect of my project now, and have discovered that
calculated fields and conditional formatting can quickly overburden a
continuous form, and result in screen flashing, and looping struggles.
So, I discovered that an SQL Query can substitute and eliminate some
of these problems. Now I struggle with attempting to reference a
textbox in the row with my SQL query (not doing well with that), and
additional problems with getting a user defined function that performs
many calculations based on public variables to somehow fit in, and I’m
not doing to well with that either.

It’s probably time for the book.

Thanks Again
Greg




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.