472,372 Members | 1,559 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,372 software developers and data experts.

Subform not consistently updating from RecordSource in Access 97

I have an Access 97 application that has a basic form (Transcript) and
subform. The subform has a query as a recordsource that returns
records from a table:

SELECT DISTINCTROW Transcript.NCID, Transcript.TransCode,
Transcript.TransMM, Transcript.TransYY, Transcript.DateKeyed,
Transcript.UserID
FROM Transcript
WHERE datekeyed >= begindate() and datekeyed < enddate()
ORDER BY datekeyed;

(the functions begindate() and enddate() are 2 functions I wrote to
return the date of the first of the
current month and the last day of the current month. In this case,
11/01/2006 and 11/30/2006)

The data is displayed in the subform as a datasheet. The records that
are returned are based on the date range specified by the user.

When I initially open the form, I set the default date range to the
first and last day of the current month. However, when I open up the
form/subform, the records displayed are not the records I expect, based
on the query above. What is displayed seems to be the records that were
last displayed when the user entered a different date range.

Access seems to be saving the last records displayed on the form, even
after the form is closed and is ignoring the query set up as the
subform's recordsource. If I compact the database, it seems to clear
out the problem and displays the correct records.

Anybody have a suggestion for what might be going on? I know it sounds
complicated, but I will be glad to try to explain further if needed.

Thanks!!!

Stuart

Nov 2 '06 #1
3 2113
Presumably your BeginDate() and EndDate() functions return a date value. You
might be able to solve the problem by concatenating that literal date into
the string that you assign to the RecordSource of the subform in its Open
event.

Private Sub Form_Open(Cancel As Integer)
Dim strSql As String
Const strcJetDate = "\#mm\/dd\/yyyy\#"

strSql = "SELECT DISTINCTROW Transcript.* FROM Transcript " & _
"WHERE datekeyed >= " & Format(begindate(), strcJetDate) & _
" And datekeyed < " & Format(enddate(), strcJetDate) & _
" ORDER BY datekeyed;"

Me.RecordSource = strSql
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<st***********@ncmail.netwrote in message
news:11*********************@m7g2000cwm.googlegrou ps.com...
>I have an Access 97 application that has a basic form (Transcript) and
subform. The subform has a query as a recordsource that returns
records from a table:

SELECT DISTINCTROW Transcript.NCID, Transcript.TransCode,
Transcript.TransMM, Transcript.TransYY, Transcript.DateKeyed,
Transcript.UserID
FROM Transcript
WHERE datekeyed >= begindate() and datekeyed < enddate()
ORDER BY datekeyed;

(the functions begindate() and enddate() are 2 functions I wrote to
return the date of the first of the
current month and the last day of the current month. In this case,
11/01/2006 and 11/30/2006)

The data is displayed in the subform as a datasheet. The records that
are returned are based on the date range specified by the user.

When I initially open the form, I set the default date range to the
first and last day of the current month. However, when I open up the
form/subform, the records displayed are not the records I expect, based
on the query above. What is displayed seems to be the records that were
last displayed when the user entered a different date range.

Access seems to be saving the last records displayed on the form, even
after the form is closed and is ignoring the query set up as the
subform's recordsource. If I compact the database, it seems to clear
out the problem and displays the correct records.

Anybody have a suggestion for what might be going on? I know it sounds
complicated, but I will be glad to try to explain further if needed.

Thanks!!!

Stuart

Nov 3 '06 #2
Thanks Allen for your response. This seems to have fixed the problem.
I am curious, though, why having this in a query in a record source for
the subform does not work? If I just opened up the subform, then it
was always displaying the correct records.

Nov 3 '06 #3
Stuart, it's difficult to answer that question without knowing what your
functions do.

It appears that they take no arguments, so Access does not see them as
dependent on anything, and therefore does not see a need to requery them. If
they actually read a value from a form or something like that, they do have
dependcies that are not obvious to Access.

Assigning the literal values at the time they need to be updated ensures
they are right, and is much more efficient and reliable, so you have avoided
the whole dependencies issue.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<st***********@ncmail.netwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
Thanks Allen for your response. This seems to have fixed the problem.
I am curious, though, why having this in a query in a record source for
the subform does not work? If I just opened up the subform, then it
was always displaying the correct records.

Nov 4 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: CSDunn | last post by:
Hello, I have a combo box (Combo7) that needs to call a function during the After Update event of the combo box. The function resides in an Access 2000 ADP Module called MMAnswerData_code. The...
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
12
by: MLH | last post by:
I have created two forms: frmBrowseNegsMainform and frmBrowseNegsSubform. I put a subform control on the first of these. The SourceObject property for the subform control is, of course,...
4
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the...
9
by: robert d via AccessMonster.com | last post by:
I'm not sure why the following isn't working. The subform loads correctly, but no data is displayed. I'm certain that there is data and I have checked that the SQL statement does in fact return...
14
by: Kurt | last post by:
I have an unbound main form with an unbound subform. frmProjects fsubProjectList Using combo boxes, the user can select several search criteria on frmProjects and then click a command button....
2
by: shifty shaker | last post by:
I need to get at a subofmr's recordsource in code. I want to change the recordsource dynamically. I thought this would be straight forward..but I keep getting errors. On Event ...
2
by: David W. Fenton | last post by:
I think at various times we've all encountered this problem: A subform is on a main form. From the code of the main form we refer to some property of/control on the child form thus: ...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.