military donut
asked on
Return # of Records from Query
Hello,
I have a form that has
2 fields
Date Field
Combo Box
I have a query that has these two fields with this in the two fields respectively:
[Forms]![Copy Of QRY_MG_3055-1]![Inspected]
[Forms]![Copy Of QRY_MG_3055-1]![DateEntere d]
I have a button to click Run Query
I want a field on my form to return the total number of Records the Query comes up with.
right now the query comes up and I don't want that anymore....I just want a field to be hidden and then visible when the button is clicked to reveal the # of records.
Any help is appreciated...
Ernest
I have a form that has
2 fields
Date Field
Combo Box
I have a query that has these two fields with this in the two fields respectively:
[Forms]![Copy Of QRY_MG_3055-1]![Inspected]
[Forms]![Copy Of QRY_MG_3055-1]![DateEntere
I have a button to click Run Query
I want a field on my form to return the total number of Records the Query comes up with.
right now the query comes up and I don't want that anymore....I just want a field to be hidden and then visible when the button is clicked to reveal the # of records.
Any help is appreciated...
Ernest
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I can say I had those fields on the SQL declared as I listed them respectively...I was trying Gustavs but still trying to get it to work, but nothing ...same thing zero records ....
Perhaps DCount will work...do I put this parameter on the button to show on this first idea...making the field visible?
Perhaps DCount will work...do I put this parameter on the button to show on this first idea...making the field visible?
You may need to reverse the sequence of the parameters:
qdy.Parameters(1).Value = lngInspected
qdy.Parameters(0).Value = datDateEntered
/gustav
qdy.Parameters(1).Value = lngInspected
qdy.Parameters(0).Value = datDateEntered
/gustav
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK....
So this morning I finally felt a little clearer on reading everything here.
Here is what I have:
1 Form with 3 fields
Field 1: DateEntered (with date picker)
Field 2: ComboBox (using a list, yes, or no)
Field 3: TextBox (unbound)
Then I have a
Command Button...
Here is what I finally came up with using everyone's ideas:
Private Sub RunQry_Click()
If DCount("Inspected", "qry_MG3055-1") = 0 Then
MsgBox "there are no files for that day, try again"
Exit Sub
Else
Me.txt_RecCount = DCount("Inspected", "qry_MG3055-1")
Me.lbl_RecCount.Visible = True
Me.txt_RecCount.Visible = True
End If
End Sub
It finally works just as I have wanted. What I am understanding from the comments above is that that query will run first based off of the fields on the form and output the data on the unbound textbox I have hidden and unhide that if there is data in the query.
On the query I have the original
[Forms]![Copy Of QRY_MG_3055-1]![Inspected]
[Forms]![Copy Of QRY_MG_3055-1]![DateEntere d]
listed in each field as appropriate. That way the data is being pulled from the form.
Thanks!
Later I will be adding the report and I will output the total # of Records based on the selection on a report that lists the records.
Thanks!
Everyone deserves the credit...
So this morning I finally felt a little clearer on reading everything here.
Here is what I have:
1 Form with 3 fields
Field 1: DateEntered (with date picker)
Field 2: ComboBox (using a list, yes, or no)
Field 3: TextBox (unbound)
Then I have a
Command Button...
Here is what I finally came up with using everyone's ideas:
Private Sub RunQry_Click()
If DCount("Inspected", "qry_MG3055-1") = 0 Then
MsgBox "there are no files for that day, try again"
Exit Sub
Else
Me.txt_RecCount = DCount("Inspected", "qry_MG3055-1")
Me.lbl_RecCount.Visible = True
Me.txt_RecCount.Visible = True
End If
End Sub
It finally works just as I have wanted. What I am understanding from the comments above is that that query will run first based off of the fields on the form and output the data on the unbound textbox I have hidden and unhide that if there is data in the query.
On the query I have the original
[Forms]![Copy Of QRY_MG_3055-1]![Inspected]
[Forms]![Copy Of QRY_MG_3055-1]![DateEntere
listed in each field as appropriate. That way the data is being pulled from the form.
Thanks!
Later I will be adding the report and I will output the total # of Records based on the selection on a report that lists the records.
Thanks!
Everyone deserves the credit...
ASKER
Great work and fantastic in asking questions and getting me to think through more...
ASKER
I know that there is records, I can't figure out why
The date field may be wrong because if I do this manually it works.
How should the date field look like unbound? I want the date picker to come up...