Access 2002 - Windows NT - Frames/Options

  • Thread starter Thread starter Abby
  • Start date Start date
A

Abby

I need to put two addresses on a form. One is a standard
address that will always be the same. If appropriate, I
want the user to chose it. If not appropriate, I need the
user to type an address in a text box. How is the best
way to handle this? I thought about using frames/option
group but I have been unable to put the standard address
on the form and show it as a selection.
 
Hi,


A possible solution is to not show the control really bound to the real
address in the form.

In the BeforeUpdate event of the FROM, assign that hidden control
somehow like this:



Me.RealAdd.Value = Nz( Me.AlternativeAddress, Me.ConstantAddress )


Doing so, if the user typed something in the alternative address, that one
will be picked, else, the "constant" address would be.


To complete the job, you also need to write some code in the onCurrentEvent:


If Me.RealAdd <> Me.ConstantAddress Then
Me.AlternativeAddress = Me.RealAdd
Ed If


so that the end user can see, if moving back to a saved record, that the
constant address has been "typed over" by another address (or provide any
kind of similar feed back).



Hoping it may help,
Vanderghast, Access MVP
 
Hi, Michel-

Thank you for the information you provided. I found the
BeforeUpdate event, but I cannot find the onCurrent
event. I have some experience in VBA in Word but none in
VBA in Access. Can you give me some more detailed
information on how to get this code into my textbox? I am
thinking I need to call my textbox "RealAdd" and then have
something assigned as ConstantAddress and something else
named AlternativeAddress but I am not sure what exactly.

Thanks.
-Abby
 
Hi, Michel-

Maybe the onCurrent event is called something else in
another version. These are what I see:
OnClick
OnGotFocus
OnEnter
Would any of these be the equivalent of onCurrent?
Also, I assume I need to create 3 unbound texboxes. One
called RealAdd with nothing in the default; one called
AlternativeAddress with nothing in the default; and one
called ConstantAddress with something my constant address
typed in as the default. Am I correct?
Thanks again!
-Abby
 
Hi Again, Michel-

I am sorry I have sent you so many messages but I have
figured out exactly what you meant with your code and
where to put it. I put everything in the code of the
FORM. I originally misunderstood. I thought you meant I
was supposed to put the code in the events of the fields.
Everything is working PERFECTLY. Thank you so much. I
will be able to use this information again with another
database/form I am working on. Your information is
invaluable. Have a GREAT day!

-Abby
 
Michel-

Your code works perfect. I still end up having a default
for this field though which is not want I want. I want to
force the user to put something in the AlternativeAddress
field. Sometimes this address will be the constant which
I would like the user to enter with initials (such as RRP)
but will end up printing on a report as a full name and
address for RRP. Can I write code or create a macro to
make this change at runtime in my report? Can I still use
the BeforeUpdate code you gave me? I may need to add
another field to the Nz(FirstField, SecondField,
ThirdField). I think I need to change the (cancel as
integer) or something, I am not sure. Thanks again!
-Abby
 
Hi,


If you need a value, it is preferable to check it in the onExit
event in the text edit CONTROL. Check about:


If 0=len(Me.TextBox & vbCharNull) Then
MsgBox ...
Cancel=true
End If



If you need extra information, I would use another control (one
information implies one field). It seems that a combo box with a not in list
event (to be sure the selection is a valid one, one in the list) would be
appropriate.



Hoping it may help,
Vanderghast, Access MVP
 
Back
Top