Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Mask Text Box - will not accept info from MS Access

Hey all!
New the forum but not the site. This is a VERY resourceful website.
Thanks to everyone that helps out!

I'm trying to retrieve info from a MS Access Database with a form in my program. The info in the database is phone numbers.

I'm trying to get it out of the database into the form to a Mask Edit.

Here is the code I'm using that doesn't work.

' recordset to compair text box with record
Dim rsSearch As ADODB.Recordset
Set rsSearch = New ADODB.Recordset

With rsSearch
.ActiveConnection = conAircraft_Caddy
.CursorLocation = adUseClient
.CursorType = adOpenForwardOnly
.Source = "SELECT * FROM Fields WHERE (Fields.fldFieldName) like '" & lblFName.Caption & "'"
.Open
' if end of file is true then display message and return to main form
If rsSearch.EOF = True Then
On Error GoTo SaveErrorHandler:

' error handler
SaveErrorHandler:
'display msgbox "not found"
gstrMessage = "That name was not found in the database."
gstrTitle = "Search By Record"
gintStyle = vbOKOnly
gintResponse = MsgBox(gstrMessage, gintStyle, gstrTitle)
MousePointer = vbDefault
Unload Me
Exit Sub
Else

' put info from database into variables
gstrNumber = !fldNumber

' put info from variables into text boxes on main form
With frmFields
.mskPhone.Container = gstrNumber
End With
End If
End With

As soon as it hits the END WITH it drops the data and continues to load everything to the new form except for the phone number from this recordset.

Any help would be HUGELY appreciated.
Thanks guys!
Shawn
[1910 byte] By [Synergy] at [2007-11-11 9:57:30]
# 1 Re: Mask Text Box - will not accept info from MS Access
You are not assigning the value to the control properly. The Container Property is used when you want to change the Parent object of a control, like forcing the control to be contained within a picture box control or some other container type of control.
All you need to do is assign it directly to the control or to the controls text property like so:
.mskPhone = gstrNumber
...or...
.mskPhone.Text = gstrNumber
Ron Weller at 2007-11-11 17:23:33 >
# 2 Re: Mask Text Box - will not accept info from MS Access
Perfect! Thanks Ron.
I have no idea why I thought I had to use .container.
Synergy at 2007-11-11 17:24:33 >