I have a Form which will help me to filter out the records I want for my Report. The button will open the Report On Click.
This is the code in the button:
Private Sub Open_OEE_Click()
DoCmd.OpenReport "OEE_Report", acViewReport, , , acWindowNormal
End Sub
I keep getting the error:
I also have placed the query in my report under the Record Source as:
SELECT * FROM 3_OEE WHERE ((([3_OEE].RecordID)=Forms![3_OEE_Report]!cboRecordID) And (([3_OEE].Date_Recorded)=DateValue(Forms![3_OEE_Report]!Date_Recorded)) And (([3_OEE].MC_No)=Forms![3_OEE_Report]!cboMCNo) And (([3_OEE].Product)=Forms![3_OEE_Report]!cboProduct));
I want to search based on one criteria (text box or combo box) and not all four at once.
Am I missing out something?
MS-Access does tend to go a bit overboard with the brackets. Make the report's Record Source a bit easier to read by trimming out the unnecessary ones. You also need to get your date criterion in the right format - Access always uses US formatting in SQL queries and needs # signs around the date:
SELECT * FROM 3_OEE
WHERE [3_OEE].RecordID = Forms![3_OEE_Report]!cboRecordID
And [3_OEE].Date_Recorded = Format(Forms![3_OEE_Report]!Date_Recorded, "\#mm/dd/yyyy\#")
And [3_OEE].MC_No = Forms![3_OEE_Report]!cboMCNo
And [3_OEE].Product = Forms![3_OEE_Report]!cboProduct;
I would also suggest creating a named query for this and setting the report's Record Source to the named query. You can then test the query in isolation without having to run the report (but make sure the Form is open and the relevant controls are populated).
I asked for help from another source.
Answer to Question
Related
I have designed report in 10g. When I call report through forms 10g than report executed but do not display anything. Kindly help me what I have to do to resolve this issue. I use .rep report and desformat is PDF. One thing more when in this desformat my report started downloading instead of giving a preview in internet explorer and downloaded pdf is empty (contain nothing).
Report displays the result of a query. So the most obvious question is: does the query, when you run it outside of the Forms/Reports application, work correctly and returns the result?
If it accepts certain parameters, verify that they are correctly passed. Mind the datatype, especially if DATE is involved as people usually have problems with different format masks, NLS settings and stuff.
Also, check whether those parameters are obligatory or not. If not, report's query should contain something like
where (some_value = :parameter_value or :parameter_value is null)
Furthermore, make sure that all those parameters are passed to the report. You can display their values in the report, just to see what's going on. Open Reports Paper Layout Editor, go to the margin and - using the ampersand notation - display those values, such as
Parameter one = ¶meter_one
Parameter two = ¶meter_two
New Edition June 2, 2017
I'm creating a database for a preventative maintenance program for the equipment in my facility. We have about 70 different machines with individuals preventative maintenance instructions, and I've been able to create tables for machines with the instructions attached to them by using forms that will update the database. I created a main form that will filter which PM needs to be done based on the date that is searched that will filter through the machines in the database, access does this fine. The problem I'm currently having trouble with is finding a way to add checkboxes to this main form, and print off only the ones that are selected with a button. The plan we have is to have the mechanics to be able to print off the PM instructions, and use the print off to update the database. Is there a way this can be done with checkboxes or optionboxes?Here's a picture of the main form that doesn't have the checkbox field attached to it yetHere's a picture of the forms that will show the preventative maintenance instructions that we will be printed.
Your question is a little vague and doesn't provide any insight on what you might have tried (this would actually help us determine what you want to do). That said, based on what's given:
If you have a single checkbox and want some action to be performed when it is checked/unchecked.
Private Sub CheckboxName_Click()
If CheckboxName.Value = -1 Then
'Do something
Else
'Do something else (Else is optional)
End If
End Sub
If you have multiple checkboxes you want to confirm which are checked and which aren't when a button or something is pushed you use the Controls object to cycle through all the checkboxes.
Private Sub ButtonName_Click()
Dim ctrl as Control
Dim i as Integer
For Each ctrl In Me.Controls
If ctrl.ControlType = acCheckBox and ctrl.Value = -1
'Do something (e.g., Select Case ctrl.name)
End If
End Sub
Hopefully that at least points you in the right direction.
I am a newbie at CR. I have a report that someone else created. When I use the Database -> 'Show SQL Query' command the WHERE clause has a bunch of names. How can I find out where this list of names is coming from?
SELECT "billing_tx_charge_detail_2004"."date_of_service", "billing_tx_charge_detail_2004"."v_SERVICE_CODE", "billing_tx_charge_detail_2004"."v_PROVIDER_NAME", "billing_tx_charge_detail_2004"."service_status_value", "billing_tx_charge_detail_2004"."v_client_name", "billing_tx_charge_detail_2004"."guarantor_liability", "billing_tx_charge_detail_2004"."CLAIM_NUMBER", "billing_tx_charge_detail_2004"."GUARANTOR_ID", "billing_tx_charge_detail_2004"."v_service_value", "billing_tx_charge_detail_2004"."PATID", "cw_patient_notes"."service_duration", "cw_patient_notes"."note_type_value"FROM "SYSTEM"."billing_tx_charge_detail_2004" "billing_tx_charge_detail_2004" LEFT OUTER JOIN "CWSAVPMLIVESYSTEM"."cw_patient_notes" "cw_patient_notes" ON ((("billing_tx_charge_detail_2004"."FACILITY"="cw_patient_notes"."FACILITY") AND ("billing_tx_charge_detail_2004"."PATID"="cw_patient_notes"."PATID")) AND ("billing_tx_charge_detail_2004"."EPISODE_NUMBER"="cw_patient_notes"."EPISODE_NUMBER")) AND ("billing_tx_charge_detail_2004"."JOIN_TO_TX_HISTORY"="cw_patient_notes"."JOIN_TO_TX_HISTORY")
WHERE ("billing_tx_charge_detail_2004"."date_of_service">={d '2009-07-01'}
AND "billing_tx_charge_detail_2004"."date_of_service"<={d '2009-07-31'}) AND
("billing_tx_charge_detail_2004"."v_PROVIDER_NAME"='BARNHART,SCOTT' OR
"billing_tx_charge_detail_2004"."v_PROVIDER_NAME"='BINKER,BARB MSW LISW' OR
"billing_tx_charge_detail_2004"."v_PROVIDER_NAME"='BRETNAN,BAUNEEN' OR
"billing_tx_charge_detail_2004"."v_PROVIDER_NAME"='CROWN,DWAYNE BS NCAC-I LADAC'
OR "billing_tx_charge_detail_2004"."v_PROVIDER_NAME"='COFFEE,RAMBA BA LADAC' OR
"billing_tx_charge_detail_2004"."v_PROVIDER_NAME"='DECODE,TENISE MC LMFT LADAC' OR
"billing_tx_charge_detail_2004"."v_PROVIDER_NAME"='GONSALEZ,MAREN' OR
"billing_tx_charge_detail_2004"."v_PROVIDER_NAME"='HITAN,TOM' OR
"billing_tx_charge_detail_2004"."v_PROVIDER_NAME"='KOTUE,SHEENA')
ORDER BY "billing_tx_charge_detail_2004"."v_SERVICE_CODE",
"billing_tx_charge_detail_2004"."date_of_service", "billing_tx_charge_detail_2004"."PATID"
It is found in the Report ->Select Expert command! Hooray!
I knew as soon as I posted the question I would find the answer :)
You've got some choices. It's either:
In the record selection formula (Report > Edit Selection Formula > Record)
Hard-coded in the "Show SQL Query" window (though not as likely)
In a parameter that was either saved with the report, or contains default values (even less likely)
I'm currently working on a Database which requires the following functionality:
For example given a specific project, I have a series of structures which belong to that project, which are displayed in a datasheet view on the project form. I am attempting to allow the user to on double click to navigate to that specific structure which is displayed on another form. Currently I am using filters to implement this behavior, however, this results in the filter being left on, and when I manually turn off the filter, the form I switch to returns back to the first entry.
I am using the current code on the datasheet:
Private Sub struct_name_DblClick(Cancel As Integer)
LookupValue = Me.struct_ID
Form_frm_control.pg_structure.SetFocus
Form_frm_control.subform_structure.Form.Filter = "struct_ID = " & LookupValue
Form_frm_control.subform_structure.Form.FilterOn = True
End Sub
Any help would be greatly appreciated. Thanks in advance.
It all depends on what you need to do.
If you want to display all records and navigate to the selected record, then you can use bookmark navigation:
With Forms!MyOtherForm
.RecordsetClone.FindFirst "struct_ID = " & Me!struct_ID
If Not .RecordsetClone.NoMatch Then
If .Dirty Then
.Dirty = False
End If
.Bookmark = .RecordsetClone.Bookmark
End If
End With
This assumes that the other form is open with all the records loaded.
Another approach to this problem, which I find more useful for popup situations like this, is to just open the other form as a dialog and require it be closed before returning to the calling context. In that case, you'd do this:
DoCmd.OpenForm "MyOtherForm", , , "struct_ID = " & Me!struct_ID, , acDialog
You'd then have to close the other form to get back to the original context.
You might think that with large numbers of records this would be inefficient, but it's actually very fast, as this operation is highly optimized within Access (moreso than filtering an already open form, in fact).
In Crystal reports, you can define default values for the report parameters.
For example, I might have a date range and set a default start of 12/01/2008 and a default end of 12/31/2008.
Is it possible to modify these defaults at runtime? For example:
1 - Default to the first and last days of the current month?
2 - Default to the first and last days of a proprietary company fiscal calendar? (i.e., look it up in a database)
3 - First & Last days of the current year?
You get the point. Is this possible? I'd even be open to a solution that involved running an external application to reach into the reports and modify them, if anyone knows how to do that.
Edit:
To answer the question posed by Philippe Grondier, most of these reports are run from inside an application. I was hoping for something simpler than manipulating the crystal object at runtime; I have my hands full right now with figuring out other parts of that API. I might take a look in the future, though.
Are you planning to run your crystal report from the crystal reports interface or as an add-in embedded in another program (you can for example use the Crystal Reports ActiveX Designer Runtime Support - craxdrt.dll - in VB code) ? In this last case, it is possible to manipulate every object of the report before launching it. Objects such as parameters can then be updated according to your needs.
As a simple example of such runtime update, my report printing routine will allways check if there is a field named "printedBy" in the report. In case this field is found, its value will be settled to the the domain name of the user that requests the report and will be printed out.
At an higher level, you can even reshape the report SQL string to add specific filters that can be inherited from your code. By doing so you might not even need parameters anymore: let your code add the filtering values 'on the fly'
EDIT: some code examples:
(m_rapport is a CRAXDRT.report object, ActiveSession is my current session object)
If m_rapport.ParameterFields.Count > 0 Then
For i = 1 To m_rapport.ParameterFields.Count
If m_rapport.ParameterFields(i).Name = "{?PUB_DateDebutPeriode}" Then
m_rapport.ParameterFields(i).AddCurrentValue CDate(DateValue(sessionActive.dateDebutPeriode))
End If
If m_rapport.ParameterFields(i).Name = "{?PUB_DateFinPeriode}" Then
m_rapport.ParameterFields(i).AddCurrentValue CDate(DateValue(sessionActive.dateFinPeriode))
End If
If m_rapport.ParameterFields(i).Name = "{?PUB_id_Personne}" Then
m_rapport.ParameterFields(i).AddCurrentValue StringFromGUID(clientActif.id_Personne)
End If
Next i
Endif
I also have another function to change report's datasource at runtime, so that reports can be executed on different servers/locations.
Read my posting Crystal Reports: Named-Date-Range Parameters. Maybe you'll be able to leverage this technique for your purposes.