Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Requery does not show new rows. 1

Status
Not open for further replies.

papadilbert

Programmer
Sep 24, 2004
23
US
On Form0 I have a tabbed form. On Page1 I have Form1. On Page2 I have Form2.

Form1 has a button that adds a row to Table2 that is displayed by Form2

Form2 is a continuous display form that uses a query as its Record Source to display Table2 rows.

After clicking the button on Form1 to add a row to Table2, I click on Page2. Form2 does not show the new row.

I've tried adding to the end of the button_click() routine: Forms!Form0!Form2!Form.Requery

If I exit Form0 and reopen it, Form2 displays the new row.


 
Do you get any error messages?
Does your code compile?
Do you have Option Explicit in your code General Declarations?
Is Form2 the name of the subform control on Form0? The name of the subform control is not always the same as the source object.

Can you share your actual code?

Duane
Hook'D on Access
MS Access MVP
 
How are ya papadilbert . . .
Code:
[blue]Change: Forms!Form0!Form2!Form.Requery
To    : Forms!Form0!Form2[COLOR=red yellow].[/color]Form.Requery[/blue]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Yep. Sorry, I typeo'd the post. I have the dot in the real code. It doesn't work. I tried other approaches. This is the latest...real code.

DBTracker is a tabbed form. One of the tabs holds the form "People", and another form "EmailTracker"


' Code executed from button on the People subform of DBTracker
'
' The SQL statement is built.
' The SQL statement is executed.
' A row is added to the EmailTracker table'
' The EmailTracker form is Requery'd
'
' But when the tab with the EmailTracker subform is clicked,
' The new row is not displayed.
'
' However, now with the latest change to the Requery
' statement, when another row is added, both rows are then
' displayed.
'
' It's like the first Requery was buffered. This "buffering' repeats. It's like it takes more than one new row to be added before the "Requery" will display them.


strSQL = "Insert Into EmailTracker (RecipientID, _
EmailType, EmailDatelastGenerated) values _
(" & Me!ID & " , 'Verify DBA', '" & Now & "');"

CurrentProject.Connection.Execute strSQL, , _
adCmdText + adExecuteNoRecords

Forms!DBTracker.Form.EmailTracker.Form.Requery

 
Do you understand the difference between the subform control's Name and its Source Object?

If the code is running from a subform, try:
Code:
   Me.Parent.EmailTracker.Form.Requery


Duane
Hook'D on Access
MS Access MVP
 
Yep, I know the difference. And yes, I named them the same. I'm not very imaginative :)

I tried tweaking the Requery. This works. Yippee!!!

Forms!DBTRacker.Form!EmailTracker.Form.Requery


Can someone provide a technical explanation of the difference between the above statement and the one below that doesn't work so well?

Forms!DBTRacker.Form.EmailTracker.Form.Requery

 
Ah. Is it that one refers to the Control and the other refers to the Source Object?

The light might be getting a bit brighter.
 
papadilbert . . .

What version Access? ... Its scary to find Ms.A not following her own rules. I'd expect several other form referencing lines of code presented here ... to work!

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
papadilbert . . .

I'm not so sure its the form referencing at fault. In fact I query the ADO method your using. I'm not hot on ADO yet and it would take to long for me to nail it if there is a problem. What I suggest is a DAO version in a temporary button for testing. The code for the temp button would be:
Code:
[blue]   Dim db As DAO.Database, SQL As String
   
   Set db = CurrentDb
   SQL = "Insert Into EmailTracker (RecipientID, " & _
                                   "EmailType, " & _
                                   "EmailDatelastGenerated) " & _
                           "VALUES (" & Me!ID & " , " & _
                                    "'Verify DBA', " & _
                                    "'" & Now & "');"
   db.Execute SQL, dbFailOnError
   DoEvents
   
   Forms!DBTracker!EmailTracker.Form.Requery[/blue]
Let me know how this fairs. If it works then there's some problem in your ADO ... perhaps how the connection is setup (just a guess).

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top