I cant retreive the values from the maskedit boxes

Hi folks,
my maskedit controls are working well but when I type in an account number and press find it only retreives the values from the text boxes.


This is the cmdEnter code:

Private Sub cmdEnter_Click()
Const conMsg As String = "Account numbers range from 1 to 30."
Const conBtns As Integer = vbOKOnly + vbInformation _
+ vbDefaultButton1 + vbApplicationModal

Dim udtCredit As CreditStruc
Dim strFilename As String
Dim intUserResponse As Integer
Dim intAccNum As Integer, x As Integer

On Error GoTo errHandler

intAccNum = Val(mskAccNum.Text)
dlgCom.FileName = strFilename
strFilename = "A:\Data.dat"

Open "A:\Data.dat" For Random As #1 Len = Len(udtCredit)


udtCredit.intAccNum = mskAccNum.Text
udtCredit.dteBirth = mskBirth.Text
udtCredit.strLast = txtLast.Text
udtCredit.strFirst = txtFirst.Text
udtCredit.curBalance = mskBalance.Text
udtCredit.strTelNum = mskTelNum.Text
udtCredit.intIDNum = txtIDNum.Text
udtCredit.dteDateTrans = mskDateTrans.Text
udtCredit.dteDate = lblDate1.Caption

For x = 1 To 30
Put #1, intAccNum, udtCredit
Next


Close #1
Call ClearFields
errHandler:

mskAccNum.SelStart = 0
mskAccNum.SelLength = Len(mskAccNum.Text)
mskAccNum.SetFocus

End Sub

This is the Clearfields code:

Private Sub ClearFields()
'Clear the form for the next record
Dim strMask As String

mskAccNum.Mask = ""
mskAccNum.Text = ""
mskAccNum.Mask = "###"
mskBirth.Mask = ""
mskBirth.Text = ""
mskBirth.Mask = "##/##/####"
mskTelNum.Mask = ""
mskTelNum.Text = ""
mskTelNum.Mask = "(##) (########)"
txtLast.Text = ""
txtFirst.Text = ""
txtIDNum.Text = ""
mskBalance.Mask = ""
mskBalance.Text = ""
mskBalance.Mask = "#,###.##"
mskDateTrans.Mask = ""
mskDateTrans.Text = ""
mskDateTrans.Mask = "##/##/####"

End Sub


This is the cmdFind code:


Private Sub cmdFind_Click()
Const conMsg As String = "Account numbers range from 1 to 30."
Const conBtns As Integer = vbOKOnly + vbInformation _
+ vbDefaultButton1 + vbApplicationModal
Dim udtCredit As CreditStruc, intAccNum As Integer, intUserResponse As Integer
Dim intIDNum As Integer, intIndex As Integer

On Error Resume Next

'Read record from file
Open "A:\Data.dat" For Random As #1 Len = Len(udtCredit)

intAccNum = Val(mskAccNum.Text)

If mskAccNum.Text <> "" Then
If intAccNum >= 0 And intAccNum <= 30 Then
Get #1, intAccNum, udtCredit
txtLast.Text = Trim(udtCredit.strLast)
txtFirst.Text = Trim(udtCredit.strFirst)
mskBirth.Text = Trim(udtCredit.dteBirth)
mskTelNum.Text = Trim(udtCredit.strTelNum)
txtIDNum.Text = Trim(udtCredit.intIDNum)
mskBalance.Text = Trim(udtCredit.curBalance)
mskDateTrans.Text = Trim(udtCredit.dteDateTrans)
lblDate1.Caption = Trim(udtCredit.dteDate)

Else
intUserResponse = MsgBox(conMsg, conBtns, "Unlimited Credit.")
End If
ElseIf txtLast.Text <> "" Then
For intIndex = 1 To 30
Get #1, intIndex, udtCredit
If txtLast.Text = Trim(udtCredit.strLast) Then
mskAccNum.Text = intIndex
txtLast.Text = Trim(udtCredit.strLast)
txtFirst.Text = Trim(udtCredit.strFirst)
mskBirth.Text = Trim(udtCredit.dteBirth)
mskTelNum.Text = Trim(udtCredit.strTelNum)
txtIDNum.Text = intIDNum
mskBalance.Text = curBalance
mskDateTrans.Text = Trim(udtCredit.dteDateTrans)
lblDate1.Caption = dteDate
End If
Next
End If


mskAccNum.SelStart = 0
mskAccNum.SelLength = Len(mskAccNum.Text)
mskAccNum.SetFocus
End Sub


Thankyou for any help on this point.
Ned_KellyAsked:
Who is Participating?
 
Valliappan ANConnect With a Mentor Senior Tech ConsultantCommented:
I think beckingh is right in this, since if you use a prompt character like '_' (default one), then the text property returns value including the prompt character, which also, I you can eliminate by setting the promptinclude property to false.

Cheers.
0
 
beckinghCommented:
Not sure exactly what you are looking for.  But one problem I have had is using the "Text" property rather than the "FormattedText" property.

Good luck.
0
 
Ryan ChongCommented:
Hi, any error captured?

The code in cmdEnter_Click() :

For x = 1 To 30
Put #1, intAccNum, udtCredit
Next

Correct executed?



0
 
Ned_KellyAuthor Commented:
Thanks Folks, being able to fix it so easily, I should have tried some more probing in the properties.
It was indeed the promptinclude that needed to be set to false.
Thanks again for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.