Link to home
Start Free TrialLog in
Avatar of Misty R
Misty RFlag for United States of America

asked on

Access runtime error 3251 operation not supported

WindowsXP, Access 2003, novice user.

I have an unbound form.

I've written my code as follows:

Private Sub txtUniqueName_AfterUpdate()
    Dim rst As DAO.Recordset
    Set rst = CurrentDb.OpenRecordset("hstUser")
    rst.FindFirst "[UniqueName] = " & Me.txtUniqueName
    If rst.NoMatch Then
      MsgBox "No match found on file", vbOKOnly
    Else
      MsgBox "Unique Name already on file", vbOKOnly
    End If
    Set rst = Nothing
End Sub

My problem is when I tab out of the text box I get the error msg

RUNTIME ERROR 3251 OPERATION IS NOT SUPPORTED FOR THIS TYPE OF OBJECT

the line
rst.FindFirst "[UniqueName] = " & Me.txtUniqueName is highlighted when i click on debug.

I do not know if I am getting this error because my form is unbound and maybe after_update is not the appropriate event or if there is something else I am doing wrong.

Thanks in advance for assistance.

Misty

SOLUTION
Avatar of RemRemRem
RemRemRem
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Misty R

ASKER

Thanks Rem I tried the suggestion and I get the same runtime error.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pdd1lan
pdd1lan

as above code, I tested it, and it seems working.

you need to add dbOpenDynaset in  this line Set rst = CurrentDb.OpenRecordset("hstUser",dbOpenDynaset)

and change this line to    rst.FindFirst "[UniqueName] = '" & Me.txtUniqueName & "'"
Avatar of Misty R

ASKER

Thanks to you both, the solution provided did work when I tested it on my form.