succesful RecordSetClone use evades me! Help!

  • Thread starter Thread starter Madhusudhan
  • Start date Start date
M

Madhusudhan

Hi ,

My need in the form I'm talking about is very simple. I say this
because I've seen posts that say recordset clone can be used in a snap
to find a record.

I have not used access before. The little db work I did used oracle 8i
or sql server. So the "user friendliness" of Access just doesnt work
for me.

Scenario:

I have a form with 6 fields. These are 6 fields that are bound to each
of the 6 fields in a database. In order for the user to find a
particular record, I use a combobox (called combo_Find_Conf) that lists
the primary key field - conf_id of all the records.
When the user chooses one of the conf_id from the dropdown, the 6
fields in the form need to be populated with the corresponding data.

This is the code I used:

Private Sub combo_Find_Conf_AfterUpdate()


Dim rsConf As Recordset

If Not IsNull(Me.combo_Find_Conf) Then
'Save before move.
If Me.Dirty Then
Me.Dirty = False
End If
'Search in the clone set.
Set rsConf = Me.RecordsetClone
rsConf.FindFirst "[conf_id] = " & Me.combo_Find_Conf.Value
If rsConf.NoMatch Then
MsgBox "Not found: filtered?"
Else
'Display the found record in the form.
Me.Bookmark = rs.Bookmark
End If
Set rsConf = Nothing

Next

End If

End Sub

I get the following error message:
"Compile error:
method or data member not found"
and the function "FindFirst" is where the cursor goes to after "OK"ing
the error.

Why does it say FindFirst is not found?
Do I have to use a new connection object here?
And if someone has a little extra time, I'd really appreciate how this
cloning happens in the background.

Looking to hear from you.

Madhu
 
Madhusudhan said:
My need in the form I'm talking about is very simple. I say this
because I've seen posts that say recordset clone can be used in a snap
to find a record.

I have not used access before. The little db work I did used oracle 8i
or sql server. So the "user friendliness" of Access just doesnt work
for me.

Scenario:

I have a form with 6 fields. These are 6 fields that are bound to each
of the 6 fields in a database. In order for the user to find a
particular record, I use a combobox (called combo_Find_Conf) that lists
the primary key field - conf_id of all the records.
When the user chooses one of the conf_id from the dropdown, the 6
fields in the form need to be populated with the corresponding data.

This is the code I used:

Private Sub combo_Find_Conf_AfterUpdate()


Dim rsConf As Recordset

If Not IsNull(Me.combo_Find_Conf) Then
'Save before move.
If Me.Dirty Then
Me.Dirty = False
End If
'Search in the clone set.
Set rsConf = Me.RecordsetClone
rsConf.FindFirst "[conf_id] = " & Me.combo_Find_Conf.Value
If rsConf.NoMatch Then
MsgBox "Not found: filtered?"
Else
'Display the found record in the form.
Me.Bookmark = rs.Bookmark
End If
Set rsConf = Nothing

Next

End If

End Sub

I get the following error message:
"Compile error:
method or data member not found"
and the function "FindFirst" is where the cursor goes to after "OK"ing
the error.

Why does it say FindFirst is not found?
Do I have to use a new connection object here?
And if someone has a little extra time, I'd really appreciate how this
cloning happens in the background.


FindFirst is a DAO method. It sounds like you're using ADO.
If so, I think you need to use the Find method.

I also see that you're referring to the wrong recordset
object on the Bookmark line.
 
Thanks Marsh.
Yes. I had done some meddling with the variable names and got the
recordset name wrong in one line as you pointed out. Corrected that.

I got a type mismatch error on the line:
Set rsConf = Me.RecordsetClone

This happened (i think) because Recordsetclone returns DAO's by
default.

so i tried using DAO.
I'm working on Access 2003. I was of the assumption that DAO would work
in this as well.

"Compiler error : user defined type not defined"

Its a simple "find a record" operation and man! its such a struggle.

any suggestions?
 
You have to add DAO to the project references. Open a module. On the Tools
menu choose References and browse to Microsoft DAO 3.6. Check the box to
select it and close the dialog box. Now you should be able to dim rsConf as
DAO.Recordset.

Paul Shapiro
 
Madhusudhan said:
Thanks Marsh.
Yes. I had done some meddling with the variable names and got the
recordset name wrong in one line as you pointed out. Corrected that.

I got a type mismatch error on the line:
Set rsConf = Me.RecordsetClone

This happened (i think) because Recordsetclone returns DAO's by
default.

so i tried using DAO.
I'm working on Access 2003. I was of the assumption that DAO would work
in this as well.

"Compiler error : user defined type not defined"

Its a simple "find a record" operation and man! its such a struggle.


It IS a simple operation, but you do have to keep things
straight.

Are you using DAO or ADO? Do you have the correct library
referenced? Is the other library getting in the way? (i.e.
you may think you're using DAO, but have ADO higher in the
references list so it is used for objects with the same name
in both libraries. If you really are using both libraries
then disambiguate the declarations:
Dim rsConf As DAO.Recordset
If you don't intend to use both libraries, uncheck the
reference you're not using. (it's still a good idea to
disamiguate the object declarations)
 

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

Back
Top