Using VB to Change Source Data

  • Thread starter Thread starter John Ortt
  • Start date Start date
J

John Ortt

I have a standard form which has all the fields in my Data Table.

I have left the Control source blank, so that I can assign the source when I
open the form (and change the filter depending on this also).

I have created two buttons on a form. I would like the first button to use
all the data where the subject has a "Big" value of greater than the value
input by the user. On the second button I would just like all results
returned. I have included the code I am using for the form below.The second
button works, but the first does not.

If anybody can help I would be very grateful.

John


Option Compare Database
Option Explicit
Dim stDocName As String
Dim stLinkCriteria As String

Function Open_Form()
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Function

Private Sub Button1_Click()
stDocName = "HowBigForm"
stLinkCriteria = "[Big]>" & [Enter Percentage]
Open_Form
End Sub

Private Sub Button2_Click()
stDocName = "HowBigForm"
Open_Form
End Sub
 
I've sorted it thanks......
Instead of using a parameter to work out the big percentage I've just used a
separate query.....

Here's the code.

Option Compare Database
Option Explicit
Dim stDocName As String
Dim stLinkCriteria As String

Function Open_Form()
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Function

Private Sub Button1_Click()
stDocName = "HowBigForm"
Open_Form
Forms.HowBigForm.RecordSource = "HowBig2"
End Sub

Private Sub Button2_Click()
stDocName = "HowBigForm"
Open_Form
Forms.HowBigForm.RecordSource = "HowBig"
End Sub
 
Back
Top