General discussion

Locked

AccessForm:AfterUpdateEvent code writing

By jpadilla ·
FieldName "MainDTCode" is set for DATA TYPE=text and limits the input range (1-999). I am currently utilizing 1-165 of the range.
Each one the those entries requires a corresponding "Code," limited to only: MTN,PRO,OTH,SET and RAW.
How do I write the code so that when the user iputs a number into the Form\FieldName\ "MainDTCode", it auto fills the FieldName\"Code" with one of the five alpha codes?
e.g.
If MainDTCode="54" then Code="CHG"
End If
Is this correct? Please be specific.

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by jpadilla In reply to AccessForm:AfterUpdateEve ...

Point value changed by question poster.

Collapse -

by dryflies In reply to AccessForm:AfterUpdateEve ...

Load the form that contains the field you wish to evaluate. I am not sure about your use of a text field and then limiting the input to a range of numeric values. this is problematic as numbers in a text field sort differently than numbers in a numerical field. eg in a text field, 002 sorts before 1. in a numeric field 002 sorts after one. this is important when you apply an IIF to your value.

Your selection of the after update event is correct. I am going on the assumption that you go to pure numerics to coreect your sort situation.
open a new macro in design view.
right click on its title bar and check "conditions" to make the conditions field visible. click in the conditions field, then enter "[MainDTCode] = 54" leave off the quotes when you type.
in the action field, enter "SetValue" down below there will be an "item" textbox and an "expression" text box in the item text box enter and in the expression box put "CHG"
you can also enter ranges in the conditions field by using ([MainDTCode] < 99) And ([MainDTCode] > 50)
you may also choose to use the fully qualified names of the fields to reduce ambiguity eg. "[Forms]![Member Types]![MemberTypeID]"
you can also do this in VB but a macro will cause you fewer headaches.
please rate my answer.

Collapse -

by dryflies In reply to AccessForm:AfterUpdateEve ...

Load the form that contains the field you wish to evaluate. I am not sure about your use of a text field and then limiting the input to a range of numeric values. this is problematic as numbers in a text field sort differently than numbers in a numerical field. eg in a text field, 002 sorts before 1. in a numeric field 002 sorts after one. this is important when you apply an IIF to your value.

Your selection of the after update event is correct. I am going on the assumption that you go to pure numerics to coreect your sort situation.
open a new macro in design view.
right click on its title bar and check "conditions" to make the conditions field visible. click in the conditions field, then enter "[MainDTCode] = 54" leave off the quotes when you type.
in the action field, enter "SetValue" down below there will be an "item" textbox and an "expression" text box in the item text box enter and in the expression box put "CHG"
you can also enter ranges in the conditions field by using ([MainDTCode] < 99) And ([MainDTCode] > 50)
you may also choose to use the fully qualified names of the fields to reduce ambiguity eg. "[Forms]![Member Types]![MemberTypeID]"
you can also do this in VB but a macro will cause you fewer headaches.
please rate my answer.

Collapse -

by jpadilla In reply to

Thank you!
It most certainly is more than I had. If more is required, I will repost.

Collapse -

by jpadilla In reply to AccessForm:AfterUpdateEve ...

This question was closed by the author

Back to Software Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums