"No Current Record" in Subform

M

Mike Thomas

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
 
D

David Cleave

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
 
M

Mike Thomas

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

David Cleave said:
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

Mike Thomas said:
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
 
D

David Cleave

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

Mike Thomas said:
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

David Cleave said:
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

Mike Thomas said:
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
 
M

Mike Thomas

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







David Cleave said:
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

Mike Thomas said:
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

David Cleave said:
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
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
 
D

David Cleave

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

Mike Thomas said:
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







David Cleave said:
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

Mike Thomas said:
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...

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
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
 
B

Biguana

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top