Does anyone know how to create a Form that filters out what you would like to see on reports.. I been trying to work with an example i got from micrsoft but could not make it work all the way...
I know how, but what are you trying to create? What have you got so far? What method were you trying to use? Field/table/query/report/form names are ALL helpful!
Usually I use a form with combo boxes or list boxes to allow the user to select their criteria and then build a filter in VBA based on their entries. But I am not familiar with the example from microsoft. If you could supply a few of the specifics, I would be glad to provide more help.
im pretty much trying to do what jebry is currently doing....ihave a query that has 5 fileds..
sampleno
sample_type
logindate
generator
wip
i want drop down boxes for the sample_type, generator and logindate. then after the user chooses there criteria it can either go into a preview mode on a report..or in a form...I havent decided what would be the best way for the user to view it.
im pretty much trying to do what jebry is currently doing....ihave a query that has 5 fileds..
query name = search for samples
sampleno
sample_type
logindate
generator
wip
i want drop down boxes for the sample_type, generator and logindate. then after the user chooses there criteria it can either go into a preview mode on a report..or in a form...I havent decided what would be the best way for the user to view it.
Assuming your form will have three combo boxes and a command button you can use the following:
Private Sub CommandButton_Click()
Dim Criteria As String
Dim CriteriaCount As Integer
CriteriaCount = 0
If Nz(Len(cbosample_type),0) <> 0 Then
Criteria = "sample_type = '" & cbosample_type & "'"
CriteriaCount = 1
End If
If Nz(Len(cbogenerator),0) <> 0 Then
If CriteriaCount = 0 Then
Criteria = "generator = '" & cbogenerator & "'"
CriteriaCount = 1
Else
Criteria = Criteria & " And generator = '" & cbogenerator & "'"
End If
End If
If Nz(Len(cbologindate),0) <> 0 Then
If CriteriaCount = 0 Then
Criteria = "logindate = #" & cbologindate & "#"
CriteriaCount = 1
Else
Criteria = Criteria & " And logindate= #" & cbologindate & "#"
End If
End If
This will allow only one entry for each sample type in the table. I'm not sure about the other problem. I did make the assumption that logindate was a date/time data type. If it isn't then you should substitute single quotes for the pound signs. If it is a date/time type then check your quotes to make sure they balance and be sure that you have spaces on both sides of the ampersands.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.