paulca
asked on
Masked Edit from VB to Access
When I have a masked edit box in VB as ##/##/## (Date) and a short date format in my input mask in Access, I can't retrieve the data correctly from Access if the month contains a zero as the first digit (01/11/98) will be 11/19/8 in VB masked edit box. How do I correct it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
A bit more validation - should allow empty date entry and not move on if the date is invalid
Private Sub Data1_Validate(Action As Integer, Save As Integer)
If MaskEdBox1.Text = ReplaceChar(MaskEdBox1.Mas k, "#", "_") Then
Data1.Recordset.Edit
Data1.Recordset!MyDate = Null
Data1.Recordset.Update
Else
If InStr(MaskEdBox1.Text, "_") = 0 And IsDate(MaskEdBox1.Text) Then
Data1.Recordset.Edit
Data1.Recordset!MyDate = MaskEdBox1.Text
Data1.Recordset.Update
Else
MsgBox "Invalid Date"
Action = vbDataActionCancel
End If
End If
End Sub
Private Sub Data1_Validate(Action As Integer, Save As Integer)
If MaskEdBox1.Text = ReplaceChar(MaskEdBox1.Mas
Data1.Recordset.Edit
Data1.Recordset!MyDate = Null
Data1.Recordset.Update
Else
If InStr(MaskEdBox1.Text, "_") = 0 And IsDate(MaskEdBox1.Text) Then
Data1.Recordset.Edit
Data1.Recordset!MyDate = MaskEdBox1.Text
Data1.Recordset.Update
Else
MsgBox "Invalid Date"
Action = vbDataActionCancel
End If
End If
End Sub
Hi Swilt,
I have two masked edit box in VB6 as ##/##/####(Short Date) and ##:##(Short Time).My only problem is that I can't display my 1st MsgBox.
Coding(Date) as as below:
Private Sub txtAdmdate_Validate(Cancel As Boolean)
If txtAdmdate.Text = ReplaceChar(txtAdmdate.Mas k, "_") Then
'1st Msgbox
MsgBox "Blank date"
Else
If InStr(txtAdmdate.Text, "_") = 0 And IsDate(txtAdmdate.Text) Then
'2nd MsgBox
MsgBox "Valid Date"
Else
'3rd MsgBox
MsgBox "Invalid Date"
End If
End Sub
Compile Error : Argument Not Optional.(ReplaceChar)
I appreciated a lot if you can help me.
With Thx,
Celia
I have two masked edit box in VB6 as ##/##/####(Short Date) and ##:##(Short Time).My only problem is that I can't display my 1st MsgBox.
Coding(Date) as as below:
Private Sub txtAdmdate_Validate(Cancel
If txtAdmdate.Text = ReplaceChar(txtAdmdate.Mas
'1st Msgbox
MsgBox "Blank date"
Else
If InStr(txtAdmdate.Text, "_") = 0 And IsDate(txtAdmdate.Text) Then
'2nd MsgBox
MsgBox "Valid Date"
Else
'3rd MsgBox
MsgBox "Invalid Date"
End If
End Sub
Compile Error : Argument Not Optional.(ReplaceChar)
I appreciated a lot if you can help me.
With Thx,
Celia
Private Sub Data1_Validate(Action As Integer, Save As Integer)
If InStr(MaskEdBox1.Text, "_") = 0 Then
Data1.Recordset.Edit
Data1.Recordset!MyDate = MaskEdBox1.Text
Data1.Recordset.Update
Else
MsgBox "Invalid Date"
End If
End Sub