Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textbox1 = Textbox2 1

Status
Not open for further replies.

sucoyant

IS-IT--Management
Sep 21, 2002
213
US
Good day all!

I have the following situation. I have 2 text boxes with bound data to a query, and 1 textbox that is bound to nothing.

datesold.gif


If there is no data in the "Date Sold:" box, then I would like "Text3:" to take on the characteristics of "Date Cust Moved:", that is, I need "Text3:" to say "Date Cust Moved:"
and contain the "Date Cust Moved" data.

This also needs to happen vise versa. If there is no data in the "Date Cust Moved:" box, then "Text3:" needs to take on the characteristics of "Date Sold:" and also contain the "Date Sold" data.

To make it easier, here is some basic pseudocode to help:

If Date Sold is null then
Text3.caption = "Date Sold:"
Text3.text = "Date Sold"
Else
Text3.caption = "Date Cust Moved:"
Text3.text = "Date Cust Moved"

I tried to write some VBA code like the pseudocode above, but I don't have the option of .text or .caption for the text boxes.

I hope this makes sense!




----------------------------------------
Buddha. Dharma. Sangha.
 
Oops sorry.

I messed up the pseudocode :p

THIS is the correct pseudocode:


If Date Sold is null then
Text3.caption = "Date Cust Moved:"
Text3.text = "Date Cust Moved"
Else
Text3.caption = "Date Sold:"
Text3.text = "Date Sold"




----------------------------------------
Buddha. Dharma. Sangha.
 
In the case of the VBA translation you will need for Access
is Object.control.value

An example would be Me.Mytext.Value=Me.MyText2.Value

For a label this will work -


Me.Mylabel.Caption = "Date Cust Moved"


Steve
 
Steve,

I don't have those options. I'm using VB6.

vbcode.gif


----------------------------------------
Buddha. Dharma. Sangha.
 
I even tried Me.Label4

----------------------------------------
Buddha. Dharma. Sangha.
 
There should be a Label14.Value that would work the same way as setting the caption.

And apologies on my part. I thought you were going from VB to Access and not the other way around.

:)


Steve
 
No need to apologize. I should have stated that this is all in an access report.

----------------------------------------
Buddha. Dharma. Sangha.
 
Any ideas?

I'm not able to use the .value or the .caption for some reason.



----------------------------------------
Buddha. Dharma. Sangha.
 
I would not use code. Try change the Label control to a text box and use a control source of:
=IIf(IsNull([Date Sold],"Date Sold:","Date Cust Moved:")
You can set the control source of the Text3 text box to:
=IIf(IsNull([Date Sold],[Date Sold],[Date Cust Moved])

You had several issues with your code (other than being unnecessary):
1) Text3 is the name of the text box. The label associated with the text box has its own name.
2) You don't use the "Text" property of the text box. You do use the "Value" property or leave it off.
3) You must bracket all control, field, object names that contain spaces ie: [Date Sold]
4) I always use IsNull([FieldName]) to test for null

I also recommend using "Me." when referencing form controls.



Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Thank you.

________________________________________
BUDDHA.gif
Buddha. Dharma. Sangha.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top