Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile Error on Module Function 1

Status
Not open for further replies.

BV874

Technical User
Nov 23, 2009
33
0
0
US
Hello,
I have the following code that gives me a compile error: invalid use of new keyword. I have a form that reps can edit if they are in the table tblHOUSING_REPS. They can edit the contents of the form by clicking an edit button. When they do that I get the compile error which higlights the FUNCTION line in yellow and DIM RS As New Recordset in gray. I have checked my spelling all over and cannot find any errors.

Function InHOUSING(Value As Variant) As Boolean
Dim Good As Boolean
Dim User
Dim MySQL As String
Dim RS As New Recordset

User = fOSUserName()
Good = False

MySQL = "select [HOUSING_REP] from [tblHOUSING_REPS] where [HOUSING_REP] > '' order by [HOUSING_REP]"
RS.Open MySQL, CurrentProject.Connection, adOpenStatic, adLockOptimistic
If Not RS.EOF Then RS.MoveFirst
While Not RS.EOF
If User = Trim(RS.Fields("HOUSING_REP")) Then
Good = True
RS.MoveNext
Else
RS.MoveNext
End If
Wend
InHOUSING = Good

End Function
 
Have you tried this ?
Dim RS As New DAO.Recordset

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
OOps, I meant this:
Dim RS As New ADODB.Recordset

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV! That worked perfectly!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top