Re: NoCurrent record error when calling ReQuery on a subform

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




kingston via AccessMonster.com wrote:
I don't think that this conditional is working the way you want it to:

"If Not rs.EOF Or Not rs.BOF Then"

Is this where the error occurs? Also, when you set rs, are you sure that
there is a recordset at the Me level? Is the subform where the recordset
resides?

Anja wrote:
Hi everyone,

I am running Access and am using VBA to make a custom app.

I have a tab control and one of the pages has a subform. I query the
currently selected record in the subform by overriding the 'On Current'
event as follows:

Private Sub Form_Current()
Dim rs As Recordset

Set rs = Me.Recordset

If Not rs.EOF Or Not rs.BOF Then
MsgBox rs![FormalName]
End If

End Sub

This works fine. Now, I wanted to requery the subform everytime the tab
control changs pages as the underlying records might have changed.

So, I did the following:

Private Sub TabCtl6_Change()
Me.SuppliersWithUnknownCategories_V_subform.Form.Requery
End Sub

However, this always ends up in the previous method with the error "No
current record.".

I tried Refresh, Recalc and other methods but they do not seem to
refresh the data.

Any ideas how I can query the subform data again properly?

Any help is greatly appreciated.

Thanks,
Anja

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/200610/1

Hi,

Thanks for the reply. The recordset is definitely there. It works fine
normally... only when I call ReQuery after the tab change event
happens, that is fails.

The error happens on the line:

MsgBox rs![FormalName]

Thanks,
Anja

.



Relevant Pages

  • Re: Commits and Rollbacks
    ... form (the subform) or a different record. ... Are you even sure you need a transaction? ... Private Sub Form_Unload ... ' Create and assign filtered recordset for subform. ...
    (microsoft.public.access.formscoding)
  • Re: Commits and Rollbacks
    ... transactions of the subform. ... Private Sub Form_Unload ... Dim qdf As DAO.QueryDef ... ' Create and assign filtered recordset for subform. ...
    (microsoft.public.access.formscoding)
  • Re: NoCurrent record error when calling ReQuery on a subform
    ... Is the subform where the recordset ... I have a tab control and one of the pages has a subform. ... Private Sub TabCtl6_Change ... Any ideas how I can query the subform data again properly? ...
    (microsoft.public.access.modulesdaovba)
  • RE: Tab thru Form, Subform fields
    ... properties....and see the 'other' tab on the properties ... The Subform fields are not listed on the Main Form Tab Order. ... > Private Sub Link_Exit ...
    (microsoft.public.access.formscoding)
  • Re: Button to navigate through subforms
    ... Private Sub Controlname_KeyPress ... If KeyAscii = 9 Then ... the end of the last subform, you have to manually click out to get to the next main record. ... Can you create an automated way of navigating through subforms so people don't have to know about CTRL/TAB when they want to go from form to form, and so when they reach the end, all they have to do is hit tab to move to the next main record? ...
    (microsoft.public.access.forms)