form report

awake2424

Registered User.
Local time
Today, 00:03
Joined
Oct 31, 2007
Messages
479
Code:
 Private Sub Command_Click ()
Dim Text239 As String
DoCmd.OpenReport "Exception Log", acViewPreview, , strWhereExeception & "      strWhereException = "[Text239] = " & Forms![Patients]!SelectException”
End Sub

I have a textbox (Text239) on a form that is only visible if a checkbox is selected. What I am trying to do is put a button on that form that will print oyt all exceptions. That is all recorde where Text239 has data in it or been selected. The code above is my attempt that I am sure needs work. The form is Patients. Thank you.
 
So then all I would need is something like:

Code:
Private Sub Command_Click ()
DoCmd.OpenForm "Patients", , , "Text239 = " & Me.Exception
End Sub

Patients is the form
Text239 is the textbox
and thhe control is Exception (which is only visible when Check237 is selected).

Thank you.
 
No, instead of Text239 you want the name of the field in the data.
 
Code:
Private Sub Command243_Click()
DoCmd.OpenForm "Patients", , , "Exception = " & Me.Check237 = 1
End Sub

The above code gives a filtered form with no records in it. There should be 5, but is it possible to list them in a table that can be printed automatically or by date range? Thank you.
 
If we're talking about a checkbox, more like:

DoCmd.OpenForm "Patients", , , "Exception = -1"

or

DoCmd.OpenForm "Patients", , , "Exception = " & Me.Check237
 
Code:
Private Sub Command243_Click()
DoCmd.OpenForm "Patients", , , "Exception = " & Me.Check237
End Sub

Data type mismatch in criteria expression and the DoCmd. line is highlighted. I tried the other as well with the same result. Thanks.
 
What's the data type of the Exception field in the table?
 
The data type for the exception field is text. Thank you.
 
Is it appropriate to compare to a checkbox then? In any case, for a text field:

DoCmd.OpenForm "Patients", , , "Exception = '" & Me.Check237 & "'"
 
I removed the checkbox as you suggested it made no sense.

Code:
Private Sub Command243_Click()
DoCmd.OpenForm "Patients", , , "Exception = '" & Me.Exception & "'"
End Sub

The form is called Patients
The field with the data in it is Exception
and the control is Exception

If there are 40 records in the database and only 5 have exceptions.... then when the button is pressed the result is those 5 records printing out. Thank you.
 
Are you looking for records with something in the Exception field? Try either

Code:
DoCmd.OpenForm "Patients", , , "Len(Exception & '') > 0"

DoCmd.OpenForm "Patients", , , "Exception Is Not Null"
 
That seemed to work at least now you get a filtered list of the exceptions. Is there a way to print of those? Thanks.
 
Use OpenReport on a report, using the same wherecondition.
 

Users who are viewing this thread

Back
Top Bottom