Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / August 2005

Tip: Looking for answers? Try searching our database.

"No Current Record" in Subform

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike Thomas - 03 Aug 2005 14:55 GMT
In Access 2000, I have a form containing a subform.  There is a button in
the main form which needs firstly to get the id of the selected record in
the subform.

Under certain conditions, it looks like no record is selected in the
subform, eventhough the first row does appear to be selected.

The error being returned is # 3021, "No Current Record".

I am trying to find a way to test for this condition in the button's click
event, but have not yet been successful with commands such as:

IF me.subformx.form.recordset.bof = true...
etc.

What is a reliable way to do this?

Many thanks
Mike Thomas
David Cleave - 03 Aug 2005 15:11 GMT
Errr...

I would use:

If ([Forms]![Name Of Form]![Name Of Subform].Form.Recordset.RecordCount = 0)
Then
....Do dah do dah
End If

I haven't tested this so if it ain't happening let me know.

Cheers

David

> In Access 2000, I have a form containing a subform.  There is a button in
> the main form which needs firstly to get the id of the selected record in
[quoted text clipped - 15 lines]
> Many thanks
> Mike Thomas
Mike Thomas - 03 Aug 2005 18:45 GMT
Thanks David,

That one does not work - I tried earlier.  Assuming there are rows
displayed, it will always return the row count, even though no row is
selected and there is no 'current record'.

I am trying to do this without error trapping.

Thanks
Mike Thomas

> Errr...
>
[quoted text clipped - 32 lines]
>> Many thanks
>> Mike Thomas
David Cleave - 04 Aug 2005 09:28 GMT
Hi Mike

I'm not entirely sure I've understood what the problem is. Are you saying
the subform is displaying records, but when you use code to get a value from
the selected record, it says 'No current record'?

Is one of the records selected then?

David

> Thanks David,
>
[quoted text clipped - 43 lines]
> >> Many thanks
> >> Mike Thomas
Mike Thomas - 05 Aug 2005 14:24 GMT
That's right.  When you first enter new record, eg after the ON CURRENT
method has fired and the new record, along with the attached child records
are displayed in the subform, no record is actually selected, even though
the first one will have the selection arrow lit up next to it.

When you try to access the 'highlited' record in the subform, for example:

lngID = Me.MySubForm.Form.recordset!RecordID

You get the "No Current Record" error.

Thanks
Mike Thomas

> Hi Mike
>
[quoted text clipped - 57 lines]
>> >> Many thanks
>> >> Mike Thomas
David Cleave - 08 Aug 2005 09:23 GMT
I might know what this is. Are you saying the OnCurrent event on the parent
form is referring to a record in the subform?

This is a serious problem with Access imho. The parent form's OnCurrent
event will trigger before the subform has loaded its own records. Thus if the
parent form's OnCurrent event refers to records in the subform (which haven't
loaded yet), an error occurs.

Is that what is happening in your database? Does the OnCurrent event in the
parent form refer to child form records?

David

> That's right.  When you first enter new record, eg after the ON CURRENT
> method has fired and the new record, along with the attached child records
[quoted text clipped - 71 lines]
> >> >> Many thanks
> >> >> Mike Thomas
Biguana - 09 Aug 2005 11:37 GMT
Mike,

I've got a very similar problem (although I appreciate that's not very
helpful for you).

My buttons are actually on the detail of the continuous form in the
subform, so when you click one, that record must be (a) loaded and (b)
selected, by definition, but "No Current Record".

Like you BOF and EOF are both false and the Recordcount returns a
positive integer value.  The annoying thing is that it seems very
intermittent and I can't pin down the conditions exactly (although it
does seem more frequent when there are less records (or just one
record) in the subform recordset).

Again like you I'd rather avoid having to handle the error because I
see no reason for it, and that wouldn't solve the problem because I'd
still need to get that record ID...

Seems like a bug.  Any ideas anyone?

Tim
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.