J
jrsmoots
I'm revising an access app to link to SQL Server 2005 via ODBC.
I have forms that contain subforms. In some cases I have a Master form,
which hosts a subform, that in turn has its own subforms.
In the Access-Only version of this app, subforms were linked using the Link
Child/Master fields in design view. When accessing Access tables (linked),
everything worked fine. I could add new records to the subforms.
Linked to SQL Server 2005 via ODBC, I find that when I add a new record to a
subform, sometimes (not always), the record disappears, and other records
appear, records that are in the underlying table, but are NOT part of the
current data set. Very disturbing. It's like the subform forgets it's filter
(which was set using the Link Master/Child form functionality).
I've also noticed that on a single form, if I try adding a record via code,
using:
'Add new record
DoCmd.GoToRecord , , acNewRec
Sometimes Access will show me a record already in the database, instead of
creating a new record.
Upon further investigation, it appears that Access creates the new blank
record, but the focus doesn't stay on the new record.
This is driving me somewhat batty, since the behaviors are erratic. The
first time a try and add a new record, I get the weird results. The 2nd, 3rd,
4th, behave normally.
So, now I have this workaround:
1. All subforms have SQL Statement as their record source, restricing them
to showing rows that are related to their parent.
2. On the After Update of the subforms, I've added:
me.parent.refresh
me.refresh
To force the subforms parent to update, and then the subform. (refreshing
just the current subform doesn't solve the problem 100%).
The above refresh (two refreshes) is appears to work reliably, but it causes
blinking of the form as the refreshes occur, and messes with using the tab
key to go to a new record on continuous forms.
Has anyone seen this weird behavior, and/or does any one have a more elegant
solution for ensuring that subforms always display the correct data.
On the single forms (no subforms), I've gone ahead and created stored
procedures to add the new record, return the @@Scope_Identity, which I then
use to set the record source of the form, ensuring I only see the one record
I want to see. This seems to work fine, but I would hate to have to do this
for every form in this Access app.
And yes, I know I should move to VB.NET I'm working on that too!!
Thanks in advance!!
I have forms that contain subforms. In some cases I have a Master form,
which hosts a subform, that in turn has its own subforms.
In the Access-Only version of this app, subforms were linked using the Link
Child/Master fields in design view. When accessing Access tables (linked),
everything worked fine. I could add new records to the subforms.
Linked to SQL Server 2005 via ODBC, I find that when I add a new record to a
subform, sometimes (not always), the record disappears, and other records
appear, records that are in the underlying table, but are NOT part of the
current data set. Very disturbing. It's like the subform forgets it's filter
(which was set using the Link Master/Child form functionality).
I've also noticed that on a single form, if I try adding a record via code,
using:
'Add new record
DoCmd.GoToRecord , , acNewRec
Sometimes Access will show me a record already in the database, instead of
creating a new record.
Upon further investigation, it appears that Access creates the new blank
record, but the focus doesn't stay on the new record.
This is driving me somewhat batty, since the behaviors are erratic. The
first time a try and add a new record, I get the weird results. The 2nd, 3rd,
4th, behave normally.
So, now I have this workaround:
1. All subforms have SQL Statement as their record source, restricing them
to showing rows that are related to their parent.
2. On the After Update of the subforms, I've added:
me.parent.refresh
me.refresh
To force the subforms parent to update, and then the subform. (refreshing
just the current subform doesn't solve the problem 100%).
The above refresh (two refreshes) is appears to work reliably, but it causes
blinking of the form as the refreshes occur, and messes with using the tab
key to go to a new record on continuous forms.
Has anyone seen this weird behavior, and/or does any one have a more elegant
solution for ensuring that subforms always display the correct data.
On the single forms (no subforms), I've gone ahead and created stored
procedures to add the new record, return the @@Scope_Identity, which I then
use to set the record source of the form, ensuring I only see the one record
I want to see. This seems to work fine, but I would hate to have to do this
for every form in this Access app.
And yes, I know I should move to VB.NET I'm working on that too!!
Thanks in advance!!