Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2006
    Location
    California, USA
    Posts
    55

    Unanswered: Move Cursor to field when autodialing

    Hello, I am not a real programmer, but I have some ability.

    I am using MSAccess... I have made a form.... frmAllFields ...
    one of the field is for contact telepone number ... CONTACTPHON ...

    I have a button to autodial, intended to dial the number in that field... when editing that form, the cursor can be in any field. The autodial feature will dial the number in the field where the cursor is at the time you push the autodial button. If I manually move the cursor to the CONTACTPHON field the number does load into the autodialer.
    My problem is, I can't seem to get the curser to move to that field when the autodial button is pushed and on the same push, dial that number. I have tried adding the line...
    CONTACTPHON.setfocus but it does not work properly... in fact it seems to jepordiaze the routine.

    Any hellp would be appreciated.

    MesaFloyd
    Last edited by MesaFloyd; 07-16-07 at 19:37.

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    I have no experience with autodialing, but can you just grab the value from the field and feed it to the autodial process, like:

    strVariable = Me.PhoneNumber

    What's the code behind the autodial button?
    Paul

  3. #3
    Join Date
    Aug 2006
    Location
    California, USA
    Posts
    55
    Hi Paul
    Here is the entire routine
    ---------
    Private Sub Command101_Click()
    On Error GoTo Err_Command101_Click

    CONTACTPHON.SetFocus 'should place cursor in the text box.

    Dim stDialStr As String
    Dim PrevCtl As Control
    Const ERR_OBJNOTEXIST = 2467
    Const ERR_OBJNOTSET = 91
    Const ERR_CANTMOVE = 2483

    Set PrevCtl = Screen.PreviousControl

    If TypeOf PrevCtl Is TextBox Then
    stDialStr = IIf(VarType(PrevCtl) > V_NULL, PrevCtl, "")
    ElseIf TypeOf PrevCtl Is ListBox Then
    stDialStr = IIf(VarType(PrevCtl) > V_NULL, PrevCtl, "")
    ElseIf TypeOf PrevCtl Is ComboBox Then
    stDialStr = IIf(VarType(PrevCtl) > V_NULL, PrevCtl, "")
    Else
    stDialStr = ""
    End If

    Application.Run "utility.wlib_AutoDial", stDialStr

    Exit_Command101_Click:
    Exit Sub

    Err_Command101_Click:
    If (Err = ERR_OBJNOTEXIST) Or (Err = ERR_OBJNOTSET) Or (Err = ERR_CANTMOVE) Then
    Resume Next
    End If
    MsgBox Err.DESCRIPTION
    Resume Exit_Command101_Click

    End Sub
    -----------------

    This routine does work without my single line CONTACTPHONE.setfocus
    Im simply trying .. when they button is pushed, to move the cursor from where ever it is to that txt field, then that number in that field will be given to the autodialer. This routine was generated by MSAccess and does work.

    still puzzeled
    Floyd

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Have you tried

    stDialStr = CONTACTPHON

    without worrying about focus?
    Paul

  5. #5
    Join Date
    Aug 2006
    Location
    California, USA
    Posts
    55
    I think the problem is where I am inserting the setfocus or strdialer inside the existing routine... it seems to break the routine...
    I am lame but where in the routine should I put either the CONTACTPHON.setfocus... or stDialStr = CONTACTPHON... or strVariable = Me.CONTACTPHON.. ?? (sorry, Im a bit out of my element<hardward guy>)

    also, when I used the stDialStr it gave an error about Duplicat Declaration...

    Floyd

  6. #6
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Just for chuckles, try this

    Code:
      Dim stDialStr     As String
    
      On Error GoTo Err_Command101_Click
    
      Const ERR_OBJNOTEXIST = 2467
      Const ERR_OBJNOTSET = 91
      Const ERR_CANTMOVE = 2483
    
      stDialStr = Me.CONTACTPHON.Value
    
      Application.Run "utility.wlib_AutoDial", stDialStr
    
    Exit_Command101_Click:
      Exit Sub
    
    Err_Command101_Click:
      If (Err = ERR_OBJNOTEXIST) Or (Err = ERR_OBJNOTSET) Or (Err = ERR_CANTMOVE) Then
        Resume Next
      End If
      MsgBox Err.Description
      Resume Exit_Command101_Click
    Paul

  7. #7
    Join Date
    Aug 2006
    Location
    California, USA
    Posts
    55

    Thumbs up

    pbaldy, UB de man,

    appears to work... thanks for clearing the trees for me (thanks also to Paul)

    Im off and running again... appreciate your help.
    Floyd

Posting Permissions

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