I got this problem. I have a form that retrieves a table data using the forms’ record source property. When the form’s opened, I set its record source property to a module’s public method RetrieveMembers. Here’s the code below.
Private Sub Form_Open(Cancel As Integer) 'set Form's record source property to retrieve a Members table Me.RecordSource = mod_JoinMember.RetrieveMembers End Sub 'mod_JoinMember Class Public Function RetrieveMembers() As String Dim strSQL As String Set strSQL = "SELECT tbl_Member.Title, tbl_Member.Gender, tbl_Member.LastName, tbl_Member.DateofBirth, tbl_Member.Occupation, tbl_Member.PhoneNoWork, tbl_Member.PhoneNoHome, tbl_Member.MobileNo, tbl_Member.Email, tbl_Member.Address, tbl_Member.State, tbl_Member.Postcode FROM tbl_Member;" RetrieveMembers = strSQL End Function
Object required error is thrown.
I couldn’t comprehend this compile error. I see no wrong with my code since recordsource is a String type property. And my module’s function Retrievemembers is returning a String value.
Why is it that it’s not satisfied with this?
Advertisement
Answer
Thanks for your help.
I fixed it. The reason was because String is not really an Object to begin with. So the ‘Set’ keyword is not needed – since you don’t need to explicitly declare String-type objects anyway!
All good now!