Syntax error trying to populate value & then navigate to another form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • emrodge
    New Member
    • Nov 2008
    • 13

    #1

    Syntax error trying to populate value & then navigate to another form

    Hi,
    Any help appreciated on this one. I've set up a simple database with 4 tables & 3 forms. The tables link together on a field called "client id" which is the ID in a table called "Clients".
    I am trying to write some code behind a button on a form called "Membership & Fee Stats" which navigates to the associated Client record on the Clients form. I was getting an error when clicking the button where the [Membership & Fee Stats].[client id] wasn't populated for some records so need to populate that field with the Client.ID field where it is < 1 (or null). I am now getting a syntax error (unsurprising as I'm a dabbler rather than a programmer!). Any help gratefully received & please excuse my lack of knowledge. Code concerned shown below:

    Private Sub Command22_Click ()
    'Make sure client id field is populated.
    Update [Membership & Fee Stats] set _
    [Client ID]=clients.id from clients join [membership & fee stats] on _
    [membership & fee stats].[Client ID]=clients.id where _
    [membership & fee stats].[client id] < 1

    DoCmd.OpenForm! "clients", , , _
    " [ID] = " & Me![Client ID]


    End Sub
Working...