Compile eror

Directlinq

Registered User.
Local time
Yesterday, 20:12
Joined
Sep 13, 2009
Messages
67
When i try to compile my database i get this error
Invalid use of property

Code:
Private Sub Combo178_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim Msg As String
        Set db = CurrentDb
        Set rs = db.OpenRecordset( _
            "[CompanyNames Query]", dbOpenDynaset)
        ' Create a new record.
        rs.AddNew
        ' Assign the NewData argument to
        ' the ActivityName field.
        rs! [CompanyNames Query].CompanyName = NewData
        ' Save the record.
        rs.update
        ' Set Response argument to indicate
        ' that new data is being added.
End Sub

The line
Code:
rs! [CompanyNames Query].CompanyName = NewData
Is where the error is occuring But the code works fine i just cant compile it.

Any ideas
Many Thanks
 
The query [CompanyNames Query] in noe a record set and is reference only the be recordset's name ( rs)


Try:

Code:
rs!CompanyName = NewData
 
If it were me, I would use an append query.

Code:
INSERT INTO target [(field1[, field2[, ...]])]
VALUES (value1[, value2[, ...])

Something like this:
Code:
Private Sub Combo178_NotInList(NewData As String, Response As Integer)

    ' append record
    CurrentDB.Execute "INSERT INTO [CompanyNames Query] ([CompanyName]) Values(""" & NewData  &   """)"

        ' Set Response argument to indicate
        ' that new data is being added.
        Response = True
End Sub
 

Users who are viewing this thread

Back
Top Bottom