Solved

I cant retreive the values from the maskedit boxes

Posted on 2001-06-12
4
171 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 49

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

759 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now