DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Mask Text Box - will not accept info from MS Access

  1. #1
    Join Date
    Dec 2006
    Alberta, Canada

    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 & "'"
    ' 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
    '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

    ' 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!

  2. #2
    Join Date
    Aug 2004
    Orange, California
    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
    .mskPhone.Text = gstrNumber

  3. #3
    Join Date
    Dec 2006
    Alberta, Canada
    Perfect! Thanks Ron.
    I have no idea why I thought I had to use .container.

Similar Threads

  1. Adding 2 images into rich text box using clib board method
    By Slatibartfast in forum VB Classic
    Replies: 2
    Last Post: 01-22-2007, 05:59 PM
  2. Replies: 4
    Last Post: 11-28-2005, 03:14 PM
  3. Replies: 0
    Last Post: 07-29-2002, 06:25 PM
  4. Script for scrolling
    By Mark in forum Web
    Replies: 3
    Last Post: 08-30-2001, 11:45 AM
  5. Replies: 2
    Last Post: 05-18-2000, 04:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center