Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2010
    Posts
    11

    Unanswered: invalid use of me keyword

    hi,
    i am trying to generate bar chart in ms acccess 2007 form i am writing code in access module only but i am facing above problem please help me out.

    the code is :
    Dim rst As DAO.Recordset
    Dim hold_Max As Double
    Dim bar_height(5) As Double
    Dim irec, i As Long
    DoCmd****nCommand acCmdSaveRecord
    Set rst = Me.RecordsetClone
    rst.MoveFirst
    hold_Max = 0
    irec = 0
    ' get max value
    Do While Not rst.EOF
    If rst!Revenue > hold_Max Then hold_Max = rst!Revenue
    irec = irec + 1
    rst.MoveNext
    Loop
    rst.MoveFirst

    'set bar heights, max height is 3.00

    For i = 1 To irec
    bar_height(i) = 3# * (rst!Revenue / hold_Max)
    rst.MoveNext
    Next

    ' adjust the barchart bars... need to change height and Top property
    ' red bar
    Form_Barchart.Form.rbar.Height = 50
    Form_Barchart.Form.rbar.Top = 4500
    Form_Barchart.Form.rbar.Top = 4500 - (bar_height(1) * 1428.57)
    Form_Barchart.Form.rbar.Height = bar_height(1) * 1428.57
    ' yellow bar
    Form_Barchart.Form.ybar.Height = 50
    Form_Barchart.Form.ybar.Top = 4500
    Form_Barchart.Form.ybar.Top = 4500 - (bar_height(2) * 1428.57)
    Form_Barchart.Form.ybar.Height = bar_height(2) * 1428.57
    ' purple bar
    Form_Barchart.Form.pbar.Height = 50
    Form_Barchart.Form.pbar.Top = 4500
    Form_Barchart.Form.pbar.Top = 4500 - (bar_height(3) * 1428.57)
    Form_Barchart.Form.pbar.Height = bar_height(3) * 1428.57
    ' green bar
    Form_Barchart.Form.gbar.Height = 50
    Form_Barchart.Form.gbar.Top = 4500
    Form_Barchart.Form.gbar.Top = 4500 - (bar_height(4) * 1428.57)
    Form_Barchart.Form.gbar.Height = bar_height(4) * 1428.57
    ' blue bar
    Form_Barchart.Form.bbar.Height = 50
    Form_Barchart.Form.bbar.Top = 4500
    Form_Barchart.Form.bbar.Top = 4500 - (bar_height(5) * 1428.57)
    Form_Barchart.Form.bbar.Height = bar_height(5) * 1428.57
    End Sub

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    You can only use Me in a Class Module or in a Report or Form (which are just special types of class module).

    I'll move this the Access forum.

  3. #3
    Join Date
    Apr 2010
    Posts
    11

    invalid use of me keyword

    thanks but if use same expression in class module it us not running it is asking for macro to run can u suggest me anyway to run the code

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    This code must be in the code module for the Form.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •