Link to home
Start Free TrialLog in
Avatar of JudithARyan
JudithARyanFlag for United States of America

asked on

VBA Compile Error - Data Member not found

I'm converting an app to Access 2010 and getting a compile error: data member not found.  Following is the code.

Public Function ServiceProcessSet(UserID, ServiceID, ProcessType) As Boolean
  Dim tmpUserID As Variant
  Dim db As Database
  Dim rs As Recordset
 
  Set db = CurrentDb
  Set rs = db.OpenRecordset("SELECT * FROM sysUsers INNER JOIN tblContact ON sysUsers.UserID = tblContact.ContactID WHERE ServiceID = " & ServiceID)
  If rs.RecordCount > 0 Then
    rs.Edit
    rs!ProcessType = ProcessType
    rs.Update
  Else
    DoCmd.SetWarnings False
    DoCmd.RunSQL ("INSERT INTO SysUsers(WSID,UserID,ServiceID,DateStart,ProcessType) SELECT '" & GetWSID() & "' as WID," & UserID & " as UID, " & ServiceID & " AS SID, '" & Now & "' AS start,'" & ProcessType & "'")
    DoCmd.SetWarnings True
  End If
End Function

The error happens on the rs.edit statement.  Does this mean that the frontend needs to have the backend tables linked before the compiled?  The table referenced, SysUsers, is a linked table that is shared among all the apps on various workstations.  This routine is run during startup.  

Or is there something else wrong?

Thanks for your help.

Judith
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

try changing the declaration of these two

Dim db As Database
  Dim rs As Recordset

with

Dim db As DAO.Database
  Dim rs As DAO.Recordset
Avatar of JudithARyan

ASKER

Ray, It works!  However, I have a lot of those statements in my application.  Is there a way to edit a string in multiple VBA routines/multiple forms at once?  Or am I a dreamer?

Judith
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
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
and one more thing, it is a better practice to add Option Explicit to the top of all your modules

see this tutorial from Jim dettman


https://www.experts-exchange.com/videos/536/MS-Access-Writing-Solid-VBA-Code.html
Thank you so much, you've just made my job a lot easier!

Judith