Can t apply FindFirst to a RecordSet (method seems unavailable)

Alexandre

Registered User.
Local time
Tomorrow, 02:08
Joined
Feb 22, 2001
Messages
791
Thank you by advance for any help concerning the following:

I wrote a small sub to save in a table ("Sys_GuardVar" containing the fields "Variable": name of the saved variable, and "Value": value of the saved variable) the primary key of the last edited record on a form, when the latter is closed (Primary key: "Referencia_Contrato", which is also the name of the related control in the form) . The sub is called by the form s Unload event and looks like that:

Sub Form_Unload (Cancel AS Integer)
Dim rs As Recordset
If Not IsNull (Me.Referencia_Contrato) then
Set rs = CurrentDb().OpenRecordSet("Sys_GuardVar", dbOpenDynaset)
If Not IsNull (Me.Referencia_Contrato) then
With rs
.FindFirst "[Variable]= 'ReferenciaContratoLast'"
(To check if an existing variable of the same name "Referencia_ContratoLast " has been saved yet)

The compilation fails, saying "Member of method or data not found". It seems that .FindFirst can t apply to rs. It is not even proposed by IDE in fact (when .Find is). I have the same problem a bit further in the sub with trying to apply the method .NoMatch to rs.

The strange thing is that in the corresponding Sub Form_Load()
which reads the values from Sys_GuardVAr, .FindFirst applies perfectly to Me.RecordSetClone...

I would be gratefull for any indication on how to solve this problem.

Alex
 
Hi Alexandre,
Change this line:
.FindFirst "[Variable]= 'ReferenciaContratoLast'"

To :
.FindFirst "[Variable] = '" & ReferenciaContratoLast & "'"

after equal sign singl quote, double quote
at end double quote, single quote, double quote


That should do it.
Skip

[This message has been edited by skiphooper (edited 02-22-2001).]
 
Many thanks for your quick help.
I m gonna try.

Alex
 
Well. It did not work, and I am not so surprise. Your tip is would have to be used if Refferencia_ContratoLast were a varaible. It is not. It is the string value I am looking for in the table Sys_GuardVar.

My problem is: Can .FindFirst be applied to a Recordset defined like that:
Dim rs As Recordset
Set rs = CurrentDb().OpenRecordSet("Sys_GuardVar", dbOpenDynaset)

Where Sys_GuardVar is the name of a table in the opened database.

If yes, what is happening in my case? What is the solution?
If not, is there a way round? (with .Find for Example?)
 

Users who are viewing this thread

Back
Top Bottom