By line chart you mean a graph object on form? I supposed what you want can be accomplished, sounds like maybe code to modify the RowSource property of the graph and refresh the form. I have used VBA code to modify aspects of a graph and to refresh a graph on a form after record is saved. However, never tried changing the RowSource. Example:
Code:
Private Sub btnGraph_Click()
SaveData
Me.Refresh
FormatGraph
End Sub
Sub SaveData()
With Me
If .tbxDUW1 <> "" Then !du1 = .tbxDUW1
If .tbxDUW2 <> "" Then !du2 = .tbxDUW2
If .tbxDUW3 <> "" Then !du3 = .tbxDUW3
If .tbxDUW4 <> "" Then !du4 = .tbxDUW4
If .tbxDUW5 <> "" Then !du5 = .tbxDUW5
If .tbxMoisture1 <> "" Then !m1 = .tbxMoisture1
If .tbxMoisture2 <> "" Then !m2 = .tbxMoisture2
If .tbxMoisture3 <> "" Then !m3 = .tbxMoisture3
If .tbxMoisture4 <> "" Then !m4 = .tbxMoisture4
If .tbxMoisture5 <> "" Then !m5 = .tbxMoisture5
If .tbxBulk <> "" Then !bulk = .tbxBulk
If .tbxAbs <> "" Then !abs = .tbxAbs
If .tbxSAS <> "" Then !appfine = .tbxSAS
End With
End Sub
Sub FormatGraph()
'format Proctor graph
Dim dblDensity As Double
Dim dblMoisture As Double
With Me
dblMoisture = Nz(!omc, 0)
dblDensity = Nz(!mdd, 0)
If dblMoisture > 0 And dblDensity > 0 Then
With .gphDensity
'format y axis scale
If .Parent!Metric = True Then
dblDensity = Int(dblDensity / 10) * 10 + 50
.Axes(xlValue).MaximumScale = dblDensity
.Axes(xlValue).MinimumScale = dblDensity - 250
.Axes(xlValue).MajorUnit = 50
.Axes(xlValue).MinorUnit = 10
Else
dblDensity = Int(dblDensity) + 2 + IIf(dblDensity - Int(dblDensity) > 0, 1, 0)
.Axes(xlValue).MaximumScale = dblDensity
.Axes(xlValue).MinimumScale = dblDensity - 10
.Axes(xlValue).MajorUnit = 2
.Axes(xlValue).MinorUnit = 0.4
End If
'format x axis scale
If Int(dblMoisture) > 6 Then
dblMoisture = IIf(dblMoisture - Int(dblMoisture) > 5, RRound(dblMoisture, 0), Int(dblMoisture))
.Axes(xlCategory).MaximumScale = dblMoisture + 5
.Axes(xlCategory).MinimumScale = dblMoisture - 7
.Axes(xlCategory).MajorUnit = 2
.Axes(xlCategory).MinorUnit = 0.4
End If
'y axis label
.Axes(xlValue, xlPrimary).HasTitle = True
If .Parent!Metric = True Then
.Axes(xlValue, xlPrimary).AxisTitle.Text = "Dry Density, kg/cu.m"
End If
.Visible = True
End With
End If
End With
End Sub
If you want a "Next" button will probably need a textbox to keep track of the date criteria incremented by the code and refer to that textbox as a parameter in the graph RowSource SQL.
In your case, might be like:
Private Sub btnGraphNext_Click()
Me.textbox = Me.textbox + 1
Me.Refresh
End Sub