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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form TextBox display update On opening 1

Status
Not open for further replies.

LizardKingSchwing

Programmer
Oct 12, 2001
96
NL
Hi

I have an access form which opens when the Access 97 DB is opened in access. I have a textbox which based on the Date needs to display certain text. I need to set this text up before the form opens. Is there an OnInit or an On Open module to do this in or where abouts would I put the code to do this.

I am not too experienced with VBA programming so any info. , help , samples would be greatly received

ThanX in Advance

LK--<
 
Well yes you can get the effect that you want.

Many ways !

So here come the questions to decide which option is best .. ..

The TextBox that is to hold this info - will it ever be updated to something else by the user, or is it just a static statement of fact ?

Is the TextBox bound to an underlying table ( do you store the data or is it valid only while the form is open ) ?

If the form that this control is on bound to a table?
If so, what do you want to happen when the user moves from one record to another ? Eg Does the TextBox data get recalculated - or does it stay the same from one record to the next ?


Is there anything else appropriate that you need to tell us ?


G LS
 
The textBox will not be changed by user it is for information purposes only , the text will update when the form opens based on the date from P.C however there is a date textbox that the user can change which when changed should be reflected in the information textBox , also there is a drop down list which based on a selection the information textbox will change too. The information textbox is not related to any record or data in DB other than date textbox which as I said can be changed.

So the only recalculations of textbox would occur when user changes date in textbox or when a different drop down selection is chosen.

Thanks for your help so far

let me know the best way to do this

ThanX Again

LK--<
 
Okay so the Display is set when the form opens.

Lets set the names of this control to &quot;DateDisplay&quot;

In the Form_Open event put some code that sets the value. To do this :-
With Form in Design view click on the grey square, top left between the vertical and horizontal rules
Click on the Properties tool to display the Properties dialog box.

In the On_Open event double click in the space to the right - The words [Event Procedure] will appear.
Click on the small button on the right with three dots in it.

You are now in the On_Open event procedure.

Add code :-

Private Sub Form_Open()
DateDisplay = &quot;Today's date is &quot; & Format(Date,&quot;Medium Date&quot;)
( or whatever value you want to appear in the box .. )
End Sub

Then back to the form.
Click on the User Entry Date Field ( Lets call it 'txtDate' )
In the After_Update event :-

Private Sub txtDate_AfterUpdate()
DateDisplay = &quot;Today's date is &quot; & Format(txtDate,&quot;Medium Date&quot;)
( or whatever value you want to appear in the box .. )
End Sub

Then back to the form.
Click on the Combo box { I'm assuming that by a 'Drop down list box' you mean a combo box } ( Lets call it 'cboSelection' )
In the After_Update event :-
Private Sub cboSelection_AfterUpdate()
DateDisplay = &quot;The updated Selection is &quot; & cboSelection)
( or whatever value you want to appear in the box .. )
End Sub



I've put dummy text stings into the DateDisplay because you've not said exactly what the DateDisplay should contain.

With the above, if you change DateDisplay based on txtDate or cboSelection then it will remain showing that value when user moves to another record. Is that okay ?
If you need it to revert to the PC system date generated value then move the code from the Form's On_Open to the Form's On_Current event



'ope-that-'elps.

G LS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top