Using VB to Change Source Data

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top