Disable text fields depending upon the value in other text field retrieved using LOV in oracle forms - oracleforms

i have a form wherein i accept id of a customer and depending upon that id i retrieve details of that particular customer.
Over here i have a LOV for payment modes.
If the customer is paying by cheque, i have kept fields to accept cheque details.
But if he enters cash, i disable the cheque details fields.
Now the thing is, when i am entering new record and i select cash as payment mode, the cheque details fields are disabled. But when i save that record, the cheque details fields are again enabled.
Also when i retrieve the data from database using 'execute-query' the fields are not disabled if the payment mode is cash for that particular customer.
I want to keep the cheque details fields disabled whenever the value in the payment mode field is CASH.
Can anyone help me out with this?

For this do the following:
1. Write a procedure in program unit to disable that fields and call that procedure on payment mode field's when_validate trigger or key_next_item trigger, below is the example:
if :block1.payment_mode = 'CASH' then
disable_fields; -- disable item procedure
end if;
In block level write when-new-record-instance trigger to call that procedure to disable the fields if payment mode is cash, below is the example:
when-new-record-instance trigger code:
if :block1.payment_mode = 'CASH' then
disable_fields; -- disable item procedure
end if;

when u save the record then record status is changed to query mode.. so for showing the cheq detail fields disabled after saving and when you query the record:
(1) Disable the fields programmatically in Form Level Trigger KEY-EXEQRY
if :block1.payment_mode = 'CASH' then
set_item_property('BLOCK.Field',Update_allowed,Property_false);
Set_item_property('BLOCK.Field',insert_ALLOWED,PROPERTY_FALSE);
end if;
(2) copy the same code for disabling the fields in Form Level Trigger WHEN-NEW-RECORD-INSTANCE

Related

How to disable one field by filling a value in another field in a MS access for

I have created a pharmacy database table. In addition to other fields, I have three fields: 'TypeTxn' (Text field) with Receipt, Issue and Loan Issue as three options in a drop down menu, Qty_R and Qty_I (both number fields depicting quantity received and issued). I want, that when TypeTxn is being filled and if 'Receipt' is selected by the user, the Qty_I field should get disabled and when Issue is selected, the Qty_R field should get disabled, i.e. one should not be able to fill data in that field. My knowledge about coding is almost nil. I have tried this code, but it does not work. Can someone help me to create the above mentioned operation in the MS Access Form?
Private Sub TxnType_AfterUpdate()
' by default enable two fields Qty_R/Qty_I
Me.Qty_R.Enabled = True
Me.Qty_I.Enabled = True
' test the value entered by user in TxnType field and hide fields as required
Select Case Me.TxnType
Case "Receipt"
' if the user has entered Receipt, lock field Qty_I
Me.Qty_I.Enabled = False
Case "Issue", "LoanIssue"
' If the user has entered Issue, LoanIssue lock field Qty_R
Me.Qty_R.Enabled = False
End Sub

Report Builder 3.0 - permit user to add data in after report generated

Using Report Builder 3.0 against cubes which are produced overnight.
The report I'm designing is used to archive or transfer (physical) files for patients. Users run the report, print it & then attach it to files that are then sent to a central area which will archive/send the files on.
The report has a number of parameters which is designed to return a single patient. This all works fine.
One of the parameters (#prmReason) is a single choice on what is to happen to the files, eg, "Transfer" (transfer files to another office), "Archive - closed", "Archive - deceased", "Archive - excess" (office space is limited, so staff archive off 'older' files).
One of the fields returned is CloseReason. This field always has a value. If the field is empty in the database (as the client hasn't closed), then it will contain the value: "Unknown".
This field (amongst others) are either displayed or hidden, depending on #prmReason. Again - all working without a problem.
Now for the tricky bit.
If the #prmReason = "Archive - closed" or "Archive - deceased" then the report will display CloseReason.
The problem is if CloseReason = "Unknown" then I need to know the why the file is closed & display it on the report.
I want users to be able to choose a value from a list of closure reasons. I then want the choice to be displayed on the report. Obviously if there is a genuine reason then display this value.
So the effect I'm after is:
User selects parameters & runs report.
Report then checks to see why report is being run (eg #prmReason).
If #prmReason =("Archive - closed" OR "Archive - deceased") AND CloseReason = "Unknown"
Then somehow produce a list of CloseReasons that the user can select. This value is then displayed on the report.
I can even cope with it being a free text field. Just something so that the central area can update the database if necessary & save a phone call/email etc.
(Yes, I realise that I can have the list as a series of tickboxes that the user ticks after the report is printed, but this would be a useful ability in other reports).
EDIT: empty value of CloseReasons conflicted with stackoverflow formatting (sorry didn't review post properly). Value is actually less then symbol then the word Unknown and then greater than symbol. It doesn't really affect the problem
You could add an additional hidden parameter.
If this parameter is not set then display an small table on your report that has a list of CloseReasons.
You then set table cell's action property to open the a report, choose your existing report as the report to open but this time you can pass a value for the final parameter, which, as well as displaying the Close reason in your report, would also hide the close reason choices table described above.
UPDATE To make clear more clear.
The following is based on the Northwind sample database. I have a shared data source pointing to this database.
Create new report.
Add a data source pointing to the shared Northwind data source
Add a new data set pointing to the data source above with the following query
SELECT
EmployeeID,
FirstName, LastName, Address, City, Country, Title, Notes
FROM Employees
WHERE EmployeeID = #EmployeeID
Add some of the fields to the report to show some basic info.
We now have a simple report with a single parameter #EmployeeID
Next we want to show some actions for each employee. For flexibility, I'm making this list dynamic based on the employee's Country. This list could be static.
Create a new dataset dsActions with the following query
DECLARE #actions TABLE(ActionID int, ActionLabel varchar(20))
-- Get employees country
DECLARE #Country varchar(20) = (SELECT Country FROM Employees WHERE EmployeeID = #EmployeeID)
IF #Country = 'UK'
BEGIN
INSERT INTO #actions VALUES
(1,'Sack them'),
(2,'Buy them a pint'),
(3,'Promote')
END
ELSE
BEGIN
INSERT INTO #actions VALUES
(1,'Fire them'),
(2,'High 5 them'),
(3,'Ask them to run for office')
END
SELECT * FROM #actions
Add a table to the report to show these values.
At the moment my design looks like this. (All the expressions are simple fields from the first dataset to show the employee details, nothing special)
And when I run it I get this.
OK, now all the basics are done, we need to be able to call this report again, but with an action already chosen. We'll make the actions table clickable and pass the action's label to the report.
It's the same report, we will only ever have a single report.
First, add a new parameter called action to the report and make it hidden. Add a default value of 'noaction'.
Next we want to only show our actions table if the action parameter is set to 'noaction'. To do this, set the Hidden property of the action table (tablix) to the following
=Parameters!action.Value <> "noaction"
Next we want to add a text box that displays the result action parameter, but only when the action parameter is not noaction.
So add a text, set it's expression to =Parameters!action.Value and the hidden property to =Parameters!action.Value = "noaction"
Finally, we need to make our actions list call our report but with a specific action. To do this we need to modify the actions table.
First save the report, whatever name you choose is the name you will select as the target report as the report will call itself.
Right-click the cell that contains the ActionLabel and go to the text box properties.
Select the Action tab and then choose "Go to report". Choose the name of the report you are currently working on (this actual report as the report will call itself).
Set EmployeeID parameter to [#EmployeeID] and the action parameter to [ActionLabel]
I've used the label for simplicity but you could pass the ActionID as long as you account for this in the text box that displays the action.
Optionally you could format the text so it looks like a link,
The final design and action/parameter setup looks like this
When I first run the report I get the following...
As soon as I click one of the actions, I then get this...
Hopefully that's clear now.

Refreshing an Access form textbox if user deletes a record from table

This is my troublesome Access form:
The Count textbox outlined above is the textbox in question. It's control source is a field named "Audit Count" in the table "DB Audits". The idea of the textbox is to display a running count of how many audits a specific auditor has completed that day. To do this I have the textbox set up with a default value of:
=DCount("[Loan Number]","DB Audits","[Auditor] = fOSUserName() And [Audit Date] = Date()")+1
Assuming I'm using the DCount function correctly, this is supposed to count the number of [Loan Number] records entered in the "DB Audits" table by the auditor (whose name is found using fOSUserName()) on today's date. So, for example, when opening up the form at the beginning of the day the Count textbox would read 1 and when the auditor clicked Save and New it would increase to 2.
The problem I am having is something I encountered while doing some random tests of the form. If an auditor submitted an audit (let's say the 1st of the day), the form correctly displays the next count as 2. However, if the auditor were to delete the record from the underlying "DB Audits" table while the form was still open, if they were to enter a new record, the Audit Count field would display 2 even though it should be 1 (since the 1st record had been deleted).
How can I have the Count textbox refresh whenever someone deletes a record from the table while the form is still open? I tried the OnDelete event but I couldn't get it to work.
Use the form_delete event and do a textbox.requery

SSRS- Implementing an either or paramater

So I have a requirement for a report where the user can select the exact batch number or if they are too lazy to remember the number they can pick the owner, the year, the month then the actual creation date of the batch.
If batch number is selected no need to select all the other stuff.
When the report starts up it starts in the opposite start state than expected. The query for Owner is
IF (ISNULL(#BatchNumer, '') = '')
begin
select distinct CashReceiptOwner as Label,CashReceiptOwner as Value
from CashReceiptBatchPosted
end
I was expecting the Owner box to be active, than if batch number is not empty for it to be disabled. That is not a huge issue as the combo box is blank, the bigger issue is that the report says it is required even though it is suppose to all blanks. Now I don't want to check the allow null option because all that does is create a checkbox which the user has to select.
Hopefully I made that clear enough, does anyone what I am doing incorrectly?

Access 2007 If Statement in a Validation Rule

I have an Inventory Database and I need to add a validation rule to the quantity field when the user inputs the amount of an item into the system. I want it to stop the user if he is inputting a # greater then that which is currently in stock (calculated field). I only want this to happen when inventory is going out (Outgoing Transaction or shrinkage etc...) but not during an incoming transaction (Order Entry).
This is the rule that I've applied to the quantity field in the form but it always delivers the validation message so I'm doing something wrong.
=IIf([Forms]![ALL ORDERS]![Transaction Type]=1,>0,<=[Text9])
[Transaction Type] 1 is an Incoming order so any # greater then 0 is accepted, but if the transaction type is any other kind, then the quantity has to be less then [Text9] (current stock).
What and I doing wrong???
Thanks
This seems to work for me:
([Transaction Type]=1 And [Quantity]>0) Or ([Transaction type]>1 And [Quantity]<=[Text9])
Note, no equals.