Form Updates

fantimm

Registered User.
Local time
Today, 15:25
Joined
Jul 27, 2007
Messages
11
I have some problems with form updates, and I need to know where to run the macros to make sure everything is up to date.

So for example, at the moment I have a price in a text box and the words "+Tax" in a label next to it. Above this I have a tick box to toggle this (some sale prices include tax and some don't). So when the tick box is checked the words +Tax appear next to the price and when the box is unchecked it disappears. That works fine - the problem is in my edit form, when I am scrolling through records, the label does not disappear and reappear properly with the label. I have a macro that checks the status of the check box and updates the labels visibility accordingly, but I cannot figure out where to put it to make it work properly. I have tried running the macro in just about every field for the form, but it never does anything. I also tried applying it to the actual record navigation buttons in "Mouse Up", but it seems that mouse up runs before "On Click" (which is where the code to change records is) because when I did this it always updated the labels visibility BEFORE changing the record, so it showed the correct "+TAX" for the previous record I was viewing.

So I need the macro to run when the value of this tick box changes (already done) AND when the record being viewed changes, but it needs to be updated AFTER the record has been loaded. I would also settle for just getting it to run the macro on ANY update to the form.

It might only seem like a tiny thing, but later I am going to have a check box which makes an entire section of the form appear and disappear, so I need to make sure it works.
 
Hmmm,

have you tried using a field on the edit form that displays a value based on the control that records the 'tick' for the tax? Something along the lines of an IIf function (note the double 'I' in IIf), perhaps:
Code:
= IIf(<test>,<value if true, say "+TAx">,<value if false, say "".)

In the control source.

This should then display the correct information for each record, although I can't test it or be more specific as don't have the ability to run Access at work.

HTH

Tim
 
Why not have this as a field on your underlying table then your tick box will add it in or take it away) ie after update if x = true then field = "+ tax"
if x=false then field =" "
then your form will run smooth as its a record element,

g
 
Tim, I tried making it text box instead of a label and giving it an IIf statement in the control source like you suggested, but it didn't work.

I put: =IIf([bool+TAX?]="Yes","+TAX","")

and when I ran the form nothing appears in the text box at all.

Yeah I suppose I could give that a try Gary, although that does seem like a bit of data redundancy, even if I delete the True/False field and only have a text field. But even then I will need some code to get it to work won't I? I will need that tick box to write/delete the words "+TAX" from the field in the tables. Actually won't this give me the exact same problem? because then I will need to have the tick box be updated all the time to check the status of the +TAX text field to decide wether it should be ticked when I change records.

So no-one knows if there is a way to just have a macro run after the record being viewed changes? or just when any update occurs in the form?
 
To make things happen when you move from one record to another, you have to use the the Form_Current() sub. Don't know what you have in your macro, but running it from this event may do the job. A little bit of code would also do the job. Substitute the actual names of your checkbox and label.
Code:
Private Sub Form_Current()
 If [B][I]YourCheckBoxNameHere[/I][/B] Then
  [B][I]YourTaxLabelNameHere[/I][/B].Visible = True
 Else
  [B][I]YourTaxLabelNameHere[/I][/B].Visible = False
 End If
End Sub
Good Luck!
 
Thanks missinglinq! I put the macro in the On Current update for the form and it worked perfectly. Thats exactly what I needed. Thanks for the help.
 

Users who are viewing this thread

Back
Top Bottom