|
-
Oct 24th, 2005, 09:16 AM
#1
Access -- Using input mask as delimiter
I am using an input mask to display my information as "99/99".
When I display the contents of the textbox it appears as "1003" instead of "10/03". It also saves it this way to the database. I am trying to use the split function to break it up into 2 seperate numbers IE 10 and 03 so I can save it into the database as "10/03".
The user can also enter the values as 10/3 or 1/1 or any variation, so I cannot simply split it per 2 digits.
Does anyone know how to either save a textbox to a database including the mask, or does anyone know how to split the textbox contents by the delimiter?
Thanks,
kfcSmitty
-
Oct 24th, 2005, 10:33 AM
#2
Re: Access -- Using input mask as delimiter
The following code will split the value in your testbox based on the position of the forward slash.
VB Code:
Private Sub Text8_AfterUpdate()
Dim MasterString As String
Dim SubString1 As String
Dim SubString2 As String
MasterString = Me.Text8
'First check if the field has a forward slash
If InStr(1, MasterString, "/") = 0 Then
Me.Text8 = ""
Exit Sub
End If
'Then Set the two substrings to the values to the left and right of the forward slash
SubString1 = Left(MasterString, InStr(1, MasterString, "/") - 1)
SubString2 = Mid(MasterString, InStr(1, MasterString, "/") + 1)
'Just to prove that it works
'replace this with your code
MsgBox SubString1
MsgBox SubString2
End Sub
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
Oct 24th, 2005, 10:57 AM
#3
Re: Access -- Using input mask as delimiter
You could also use the split function to populate the data into an array..
VB Code:
Dim Values() As String
If Instr(textbox1,"/") > 0 Then
Values = Split(textbox1,"/")
Msgbox Values(0)
Msgbox Values(1)
End If
However, you may be better off placing the imput mask on the text box and the relevant field in the table below to
00/00
This will force data entry in the format of two digits followed by "/" and then two digits, if this is not entered then the user will receive a message to this affect
Danny
Never Think Impossible
If you find my answer helpful then please add to my reputation
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|