View Full Version : Solved: Inserting Day of the week on a userform TextBox
Darren
09-02-2007, 12:10 PM
Hi Captains
Two Small problems tonite
1) On a userform if I insert a labelBox is there a setting in the Properties of that label... so that the end user can enter text into it ? say a box of tomatoes
2)I have Tried to insert the day of the week in a user form hmm I can get the Now() statement to work but not the day
my code
Private Sub CommandButton1_Click()
Hide
OverHeads.Show
End Sub
Private Sub Label45_Click()
End Sub
Private Sub UserForm_Activate()
End Sub
Private Sub UserForm_Initialize()
TextBox1 = Now()
TextBox3 = Date
TextBox4 = MyWeekdayDay
End Sub
Private Sub TextBox3_Change()
Dim MyDate
MyDate = Date ' MyDate contains the current system date.
End Sub
Private Sub TextBox4_Change()
Dim MyDate, MyWeekDay
MyDate = #8/31/2007# ' Assign a date.
MyWeekDay = Weekday(MyDate) ' MyWeekDay contains 4 because
' MyDate represents a Wednesday.
End Sub
Private Sub TextBox17_AfterUpdate()
TextBox17 = Format(TextBox17, "#,##0.00")
If TextBox17.Text <> "" Then
End If
TextBox26.Text = Format(SumExpensesCash, "#,##0.00")
TextBox49.Text = Format(TextBox26.Text, "#,##0.00")
End Sub
Picture
Thanks guys and ladies
Darren
South Africa
Norie
09-02-2007, 12:31 PM
1 No, a user can't put information in a label control.
2 Try taking a look at the Format function.
Perhaps something like this?
TextBox4 = Format(MyDate, "dddd")
Though I do think you might have some declaration/scope issues to sort.:)
Darren
09-02-2007, 12:36 PM
Hi Norie
Thanks for the advice will change them to text boxes and set the tab index one to the other. I will try the day function
Kindest regards
Darren
South Africa
Darren
09-02-2007, 12:50 PM
Hi Norie
Tried what you suggested but no change in textBox4 it stays blank ?
Private Sub TextBox4_AfterUpdate()
TextBox4 = Format(MyDate, "dddd")
End Sub
Private Sub UserForm_Initialize()
TextBox1 = Now()
TextBox3 = Date
TextBox4 = Format(MyDate, "dddd")
End Sub
Private Sub TextBox3_Change()
Dim MyDate
MyDate = Date ' MyDate contains the current system date.
End Sub
Private Sub TextBox4_Change()
TextBox4 = Format(MyDate, "dddd")
End Sub
Thanks
Darren
South Africa
Norie
09-02-2007, 01:00 PM
Darren
Did you see my comment regarding declaration/scope?
You've declared MyDate within the Change event of TextBox3.
No other subs will be able to access it. ie it's not in scope
lucas
09-02-2007, 01:12 PM
Your mydate variable should be declared publicly. Not inside any one module.
Option Explicit
Public MyDate As Date
Private Sub UserForm_Initialize()
TextBox1 = Now()
TextBox3 = Date
TextBox4 = Format(MyDate, "dddd")
End Sub
lucas
09-02-2007, 01:13 PM
As Norie has already pointed out. Sorry Norie I should have refreshed before posting.
Darren
09-02-2007, 01:28 PM
Hi Norrie & Lucas
Thanks for the info still learning the queens english and the big words too.
I will get there i know it!!!
Lucas i pasted the code into the sheet and it works but it shows a Saturday should i add + 1 to the code
current code is as follows
Option Explicit
Public MyDate As Date
Private Sub UserForm_Initialize()
TextBox1 = Now()
TextBox3 = Date
TextBox4 = Format(MyDate, "dddd")
End Sub
Private Sub CommandButton1_Click()
Hide
BasicTerms.Show
End Sub
Private Sub TextBox4_AfterUpdate()
TextBox4 = Format(MyDate, "dddd")
End Sub
Private Sub TextBox3_Change()
Dim MyDate
MyDate = Date ' MyDate contains the current system date.
End Sub
Private Sub TextBox4_Change()
TextBox4 = Format(MyDate, "dddd")
End Sub
You guys are champions
Darren
South Africa
mdmackillop
09-02-2007, 01:31 PM
On a userform if I insert a labelBox is there a setting in the Properties of that label... so that the end user can enter text into it ? say a box of tomatoes
You can remove the TextBox appearance. Make BackColor transparent and SpecialEffects to Etched, for example.
Darren
09-02-2007, 01:31 PM
the current snapshot
lucas
09-02-2007, 01:33 PM
You probably need to set the date to get it to read the right day
Private Sub UserForm_Initialize()
MyDate = Date
TextBox1 = Now()
TextBox3 = Date
TextBox4 = Format(MyDate, "dddd")
End Sub
Darren
09-02-2007, 01:50 PM
Hi Guys
Thank you it works like a charm Norie, Lucas & Malcolm
If i only had 1 percent of your knowledge !!!
Thanks
Darren
South Africa
The code that works
Option Explicit
Public MyDate As Date
Private Sub UserForm_Initialize()
MyDate = Date
TextBox1 = Now()
TextBox3 = Date
TextBox4 = Format(MyDate, "dddd")
End Sub
Private Sub CommandButton1_Click()
Hide
BasicTerms.Show
End Sub
Private Sub TextBox4_AfterUpdate()
TextBox4 = Format(MyDate, "dddd")
End Sub
Private Sub TextBox3_Change()
Dim MyDate
MyDate = Date ' MyDate contains the current system date.
End Sub
Private Sub TextBox4_Change()
TextBox4 = Format(MyDate, "dddd")
End Sub
Darren
09-02-2007, 02:13 PM
Hi Malcolm
Works well as instructed, but hat to set Backstyle to transperent not color and it is super thanks Malc
Darren
lucas
09-02-2007, 02:37 PM
Hi Darren,
Nothing really going on here.....? I don't think you need it. I would think you would want it to read like the other texboxes with it's own formatting.
Private Sub TextBox3_Change()
Dim MyDate
MyDate = Date ' MyDate contains the current system date.
End Sub
MyDate is declared publicly so no need to dim it here. Then you set it but never use it.
Darren
09-03-2007, 01:08 PM
Hi Lucas
Thanks for the tidy up. Champ
Darren
South Africa
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.