RecordsetClone Problems

  • Thread starter Thread starter Eddy
  • Start date Start date
E

Eddy

In Access97 I am using the following code to display records from a table.
The code executes from a unbound comboBox named cboFind.

Forms!frm1.RecordsetClone.FindFirst "[Field1] = '" &
Forms!frm1![cboFind] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark

The code works fine. The problem occurs when I leave frm1 (Example, go to
frm2) and return to it bringing the same Field1 record. The code I use to
return to frm1 follows:

DoCmd.OpenForm "frm1", , , "Field1 = '" & Forms!frm2!Field1 & "'"
FilterOn = False
DoCmd.Close acForm, "frm2"

The code works fine also. It opens frm1 and brings up the Field1 record.
The problem is the combobox no longer works. I can't call up another record
using the cboFind field with the RecordsetClone code above. I thought
turning off the filter when returning to frm1 would help. I thought wrong.

Can smarter minds than mine see what I am doing wrong?
 
The problem got nothing to do with the RecordsetClone.

The problem is in the "WhereCondition" argument you use in
the OpenForm Method as it restricts the frm1's Recordset
to those that meet the WhereCondition criteria, usually
just one Record. Hence, even though your ComboBox works
fine, it won't be able to go to the Record corresponding
to the selected row in the ComboBox. FilterOn = False
won't help in this case as the RecordSource is already
restricted.

Instead of using the WhereCondition, use the Form_Open or
Form_Load Event of frm1 to navigate to the required Record
and you should have the full/unrestricted RecordSource
where the ComboBox can work properly.

HTH
Van T. Dinh
MVP (Access)
 
Back
Top