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

Simple addition

Status
Not open for further replies.

boboo

Technical User
Feb 18, 2002
8
AU
Ok, dont laugh, Im new at his and am wondering how I can subtract one 'text box' contents from another and put the result in another text box?
Also, does anyone know if you can display a calendar if you want to enter a date into a text box.
I know Microsoft project does this, but I was wondering if it can be done in a text box in Access

thanks heaps
 
Yes, you can. However, without some sort of code to detect that only numeric values are in the textbox, then you will have a nightmare. I'd rather not post a "bad" example, so I'll leave it up to someone else to help you out with the error checking part of it. Nate Gagne
nathan.gagne@verizon.net
AKA Nick Burns - Your Company's Computer Guy
"Would you like me to save your game of Minesweeper first?"

Like my post? Let me know it was helpful!
 
Hi,

Nate is right.You can simply do:
Test3.Text = Val(Text1.Text) - Val(Ttext2.Text)

But there is no gaurantee that the text is numeric.To guard against error you have to qualify the data, something like

Private Sub Text1_LostFocus()
If IsNumeric(Text1.Text) Then
'do nothing data good
Else
MsgBox "Invalid Data"
Text1.Text = ""
Text1.SetFocus
End If
End Sub

As to a calendar you have a choice. In components there is:
Microsoft Calendar Control 8.0
or in Microsoft Common Controls-2 6.0(sp5) there is Date and Time Picker or MonthView

Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top