kashif.special2005
Active Member
- Joined
- Oct 26, 2009
- Messages
- 443
Hi,
Scenario:-
First Form Name:- GenerateRequest
Second Form Name:- DatePickerForm
Form "GenerateRequest" Controls:- A Button (Name:- cmddate), A TextBox (Name:- TextBox1)
Form "DatePickerForm" Controls:- Other user friendly controls For Selecting a date, A Button (Caption:- "OK")
In the form "GenerateRequest" , clicking on the button "cmddate", show's the form "DatePickerForm" (this form is a custom form to select a date: replacement of datepicker), and after selecting the date, and on the click on the button "OK" the selected date value should go to the textbox "TextBox1" in the form "GenerateRequest", and should hide the form "DatePickerForm".
Problem:
When I select a date the selected date is filled in the textbox, but when I click on the button to select a date the previous selected date show's in the text box, like when the first time I click on the button to select a date, I select the date "3/2/2019" and after clicking on the button "OK" nothing happens, when again I click on the button to sect the form after the pervious date "3/2/2019" appears in the textbox, now when I select another date "4/5/2019" and click on "OK" button, the date not changed in the textbox1, now again as soon as click on the button to open the form to select the date the previous date "4/5/2019" appears in the textbox1.
I don't no what is the problem please help me.
Note:- I have public variable "datevalue" to hold the date
Button "cmddate" Click Event Code
Button "OK" Click Event Code
Thanks
Kashif
Scenario:-
First Form Name:- GenerateRequest
Second Form Name:- DatePickerForm
Form "GenerateRequest" Controls:- A Button (Name:- cmddate), A TextBox (Name:- TextBox1)
Form "DatePickerForm" Controls:- Other user friendly controls For Selecting a date, A Button (Caption:- "OK")
In the form "GenerateRequest" , clicking on the button "cmddate", show's the form "DatePickerForm" (this form is a custom form to select a date: replacement of datepicker), and after selecting the date, and on the click on the button "OK" the selected date value should go to the textbox "TextBox1" in the form "GenerateRequest", and should hide the form "DatePickerForm".
Problem:
When I select a date the selected date is filled in the textbox, but when I click on the button to select a date the previous selected date show's in the text box, like when the first time I click on the button to select a date, I select the date "3/2/2019" and after clicking on the button "OK" nothing happens, when again I click on the button to sect the form after the pervious date "3/2/2019" appears in the textbox, now when I select another date "4/5/2019" and click on "OK" button, the date not changed in the textbox1, now again as soon as click on the button to open the form to select the date the previous date "4/5/2019" appears in the textbox1.
I don't no what is the problem please help me.
Note:- I have public variable "datevalue" to hold the date
Button "cmddate" Click Event Code
Code:
Private Sub cmddate_Click()
DatePickerForm.lblControl = "TextBox1"
DatePickerForm.lblForm = Me.Name
DatePickerForm.Show vbModeless
DoEvents
Me.TextBox1.Value = datevalue
End Sub
Button "OK" Click Event Code
Code:
Private Sub ShowDate_Click()
'MsgBox Calendar1.Value
'Dim myform As Object
'Set myform = VBA.UserForms.Add(Me.lblForm.Caption)
'myform.Controls(Me.lblControl.Caption).Value = Controldd.Value
'DoEvents
datevalue = Controldd.Value
Me.Hide
End Sub
Thanks
Kashif