Promt Box

Spot On

New member
Local time
, 09:52
Joined
May 29, 2009
Messages
8
In my products subform I need to have a pop up form (ie reason for discount) when a user changes the discount field value. How do I go about this please?
 
Use the "before update" event to open a popup form...

ps Welcome to the forum
 
Thanks for that! It worked fine. But now I'm have trouble with the macro info, i think I dont have the right set up because when I look at my Query for the discount reason it adds extra line ID's
Example of query
SaleID LineID Discount Discount Reason Unit Price Extended Price
1 1 15% $99.00 $84.15
2 0% VIP Client $0.00 $0.00
1 3 15% $18.50 $14.80
4 0% VIP Client $0.00 $0.00
My macro is set up as Follows
Msg - Select Discount reason
OpenForm - Discount Reasons (window mode dialog)

Closeform -save=promt

How can I fix it?
your comments greatly appreciated
 
would adding in a promptbox in the beforeupdate do the job like:

Code:
Private Sub txt_Discount_BeforeUpdate(Cancel As Integer)
Dim stDiscountReason As String

stDiscountReason = InputBox("Please enter the reason for discount", "Reason Required")

Me.txt_Discount_Reason = stDiscountReason


End Sub

that way - everytime the txt_Discount field was updated a prompt box asking for the reason would be displayed and would store the value entered into txt_discount_reason

Ian
 
Thanks for that! It worked fine. But now I'm have trouble with the macro info, i think I dont have the right set up because when I look at my Query for the discount reason it adds extra line ID's
Example of query
SaleID LineID Discount Discount Reason Unit Price Extended Price
1 1 15% $99.00 $84.15
2 0% VIP Client $0.00 $0.00
1 3 15% $18.50 $14.80
4 0% VIP Client $0.00 $0.00
My macro is set up as Follows
Msg - Select Discount reason
OpenForm - Discount Reasons (window mode dialog)

Closeform -save=promt

How can I fix it?
your comments greatly appreciated
I think you are trying to add information using the popup to the same record you have open in the other form. This is not a good thing to do. Why don't you have a field on your main form for Discount Reason (and you can have it hidden) and then you can have the popup come up (but as an UNBOUND form) and then when the user closes it you use the close event of the popup to set the value of the hidden textbox on the main form. That way you aren't adding another record and just updating the current one. And it LOOKS to the user that something else is happening but you are dealing with it so you are only editing the single record.
 
Ian,
The code was not working for me. It errors from the start, debugging from the text in green. So I deleted txt in both areas, still did't work so I changed Me. to just Me.Discount. When I entered a value in the discount field, a pop up says no record found. What I'm trying to achieve is when the field Discount % is changed, a dialog box appears with a combo field that already has the reasons listed. The user selects the reason clicks ok and moves to the next item. This sort of worked with the macro, but was adding a new line each time the combo field was selected.
Does this make any sense:confused:
Thanks Peter


Private Sub txt_Discount_BeforeUpdate(Cancel As Integer)
Dim stDiscountReason As String

stDiscountReason = InputBox("Please enter the reason for discount", "Reason Required")

Me.txt_Discount_Reason = stDiscountReason
 
Hi Peter, you would have had to replace the txt_... with whatever your text boxes were called, I think you will need to load a separate form for the popup with a combo box on.

I have attached a sample based on your description that you should be able to see how it works and apply the same to your application.

Regards - Ian
 

Attachments

Thanks Ian,
Your sample is exactly how I want it to work. So I applied it to mine but when I click on the pop up to update, access say's it cant find the form Sbf_SalesDetail in the basic code I changed the code to reflect the form but still does not work.
Is the problem the subform?
Peter
 
Yes Peter it could be -

The pop up is launched from the after update event on the Discount textbox, if you then look at the code behind the close button on the popup form - that shows where the value will be updated to you will need to reference your Form - Subform - textbox which needs the value storing to

Regards - Ian
 
Hi Ian,
Still can't make the program work in my form. Keep getting error Access cant find Sbf_SalesDetails. Yet if I open the subform only, the program works:D
I tried adding the Sales form name as well, but still errors with cant find that form either.
How my form works is the main form is called Sales, within that there is my subform called Sbf_SalesDetails which is in a tab control box called Sales Details I cant seem to pinpoint how to make it work:(
Any more suggestions?
Thx Peter
 
Hi Peter,

OK think we might have the solution now - the reference would need to be in the format of:

Code:
Forms![Sales]![Sbf_SalesDetails]![discount reason].Value = stDiscountReason

I have attached a working sample if you do run into trouble and named the forms as you have so it should work for you.

Regards - Ian
 

Attachments

Ian,
Your a legend, It worked perfectly. I had all the criteria right except for the .Value.
Am I right in understanding that . Value = stABCD applies to a text field as well?
I really apprieciate your time and guidence
I'm sure I have other questions as I get into my program as time goes on.
Thanks heaps
Peter:D
 
Hi Peter, you are more than welcome, just glad you got your problem solved - The people on this forum has saved me from baldness on several occasions when i feel like tearing my hair out.

and... yes the ".Value = stWhatever" will work with text boxes, etc

Regards - Ian
 
And you do NOT need .value for this code. .Value is the default for most controls and so you do not need to explicitly use it except in cases like:

Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Value = 12 Then

....etc.


and if you use this syntax:

Forms("MyFormName").Controls("ControlNameHere").Value
 

Users who are viewing this thread

Back
Top Bottom