Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2004

    Unanswered: Breaking up a field into 2 fields

    I have the following code I am trying to write to break up a phone number field into seperate phone number and extension fields. I have the code working that actually breaks them up, but I need to be able to loop through the records on the form to search and break up all applicable fields. Thanks for any help:

    Private Sub Command0_Click()
     Dim rst As ADODB.Recordset
     Dim myNum As String
     Dim myPos As Integer
     Dim strFirst As String
     Dim strLast As String
     Set rst = New ADODB.Recordset
     myNum = Me.CustomerWork
     With rst
       .Open "Select * From tblCustomerPhone", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
       Do While Not .EOF
        myPos = InStr(1, myNum, "x", vbTextCompare)
        'Debug.Print myPos
        If myPos <> 0 Then
     		strFirst = Left(myNum, myPos - 1)
     		strLast = Right(myNum, Len(myNum) - myPos)
     		Me.CustomerWork = strFirst
     		Me.CustomerExt = strLast
     		'Debug.Print strFirst
     		'Debug.Print strLast
        End If
     End With
     Set rst = Nothing
     End Sub

  2. #2
    Join Date
    Jul 2004
    Nevermind, I got it.. I just used the values from the recordset instead of form values.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts