Solved

I cant retreive the values from the maskedit boxes

Posted on 2001-06-12
4
173 Views
Last Modified: 2010-05-18
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.
0
Comment
Question by:Ned_Kelly
4 Comments
 
LVL 4

Expert Comment

by:beckingh
ID: 6183668
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
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 6184388
Hi, any error captured?

The code in cmdEnter_Click() :

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

Correct executed?



0
 
LVL 9

Accepted Solution

by:
Valliappan AN earned 75 total points
ID: 6184514
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
 

Author Comment

by:Ned_Kelly
ID: 6186339
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

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question