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

connecting dates

Status
Not open for further replies.

svm

Programmer
Apr 26, 2001
44
US
Hi.

I have txtfields1.Text and txtfields2.Text defined. Txtfields1.Text refers to month and txtfields2.Text refers to Year(yy). How do I connect the two values to output only as one in table or file fieldname : BIDDATE. Appreciate any help you can give me. For example :

TxtFields1.Text (Value) = 11
TxtFields2.Text (Value) = 01

When you output this in the file should be 11/01 ? How is this defined in VB. Thanks.

 
On your form

private Sub FormatDate()as string
FormatDate = txtFields1.text & "/" & txtfields2.text
end sub

If you're just writing to a file, write FormatDate instead
of the text boxes.
If you've got bound text boxes, then don't bind txtFields1 and txtFields2, but bind txtFields3, which would be a hidden (not visible and not enabled) textbox.
For txtFields1.Change and txtFields2.Change events
do this: txtFields3.text = FormatDate

Make sure you validate thoroughly.

scarfhead
 
Hi svm, What if you define a new variable strValueToStore AS String(or dtmValueToStore As Date).

strValueToStore = Text1.Text & "/" & Text2.Text

BIDDATE = strValueToStore

Hope That helps MLK
 
Try defining a variable, storing the value of the combined text fields in the variable, and then sending that to your table. For example:


'If you're using Access, it doesn't store mm/yy format _
'dates, so you'll have to set it as a string value.

dim strMonthYear as string

strMonthYear = txtFields1.text & "/" & txtFields2.text


If the value of txtFields1.text = 11, and txtFields2.text = 1, then your output would be "11/1". To ensure a two-digit mm/yy format, you could write a procedure as follows:

dim strYear, strMonth, strMonthYear as string

'set the month
if cint(textFields1.text) < 10 then
strMonth = &quot;0&quot; & textFields1.text
else: strMonth = textFields1.text
end if

'set the year
if cint(textFields2.text) < 10 then
strYear = &quot;0&quot; & textFields2.text
else: strYear = textFields2.text
end if

'set the package for output
strMonthYear = strMonth & &quot;/&quot; & strYear

Hope this helps &quot;The night sky over the planet Krikkit is the least interesting sight in the entire universe.

-Hitch Hiker's Guide To The Galaxy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top