Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Join Date
    Apr 2004
    Posts
    182

    Unanswered: Simulate button click

    Is it possible to simulate using code a button click on a form ??

  2. #2
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    you can call button's click procedure.
    ghozy.

  3. #3
    Join Date
    Apr 2004
    Posts
    182
    Quote Originally Posted by ghozy
    you can call button's click procedure.
    Can you tell me how ?
    Thanks

  4. #4
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    after creating your button's code. you can call it by its procedure name.
    lets assume you have a button, that when you click it pop-ups a message box and says hi! the button's click code should be something like that:
    Code:
    Private Sub btFireQuery_Click()
      Msgbox "hi!"
    End Sub
    then later anywhere in your code you call this Sub with its name like any other procedure.
    Code:
     
    btFireQuery_Click
    ghozy.

  5. #5
    Join Date
    Apr 2004
    Posts
    182
    Quote Originally Posted by ghozy
    after creating your button's code. you can call it by its procedure name.
    lets assume you have a button, that when you click it pop-ups a message box and says hi! the button's click code should be something like that:
    Code:
    Private Sub btFireQuery_Click()
      Msgbox "hi!"
    End Sub
    then later anywhere in your code you call this Sub with its name like any other procedure.
    Code:
     
    btFireQuery_Click
    When I try to call it I just get sub or function not defined.

    Public Sub cmdNext_Click()
    On Error GoTo Err_cmdNext_Click


    DoCmd.GoToRecord , , acNext

    Exit_cmdNext_Click:
    Exit Sub

    Err_cmdNext_Click:
    MsgBox Err.Description
    Resume Exit_cmdNext_Click

    End Sub

    I have tried both Private and public in the first line.
    I think I am missing something very simple

  6. #6
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    I think you might need to add dyour form name before the procedure name
    like:
    Form_yourform.cmd_next_Click
    ghozy.

  7. #7
    Join Date
    Apr 2004
    Posts
    182
    Quote Originally Posted by ghozy
    I think you might need to add dyour form name before the procedure name
    like:
    Form_yourform.cmd_next_Click

    I think I have it now thanks

  8. #8
    Join Date
    Apr 2004
    Posts
    182
    Although the code is being run it is not moving on to the next record ?
    Clicking the button does move it. I am trying to capture an id from the rec and it is not changing.

  9. #9
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    could you paste the button code here?
    ghozy.

  10. #10
    Join Date
    Apr 2004
    Posts
    182
    Quote Originally Posted by ghozy
    could you paste the button code here?
    Public Sub cmdNext_Click()
    On Error GoTo Err_cmdNext_Click
    Dim mymatid1 As Variant

    DoCmd.GoToRecord , , acNext
    mymatid1 = Forms!frmEstimateComplete.Form!fsubEstDets!fsubMat sEst.Form.txtmatid
    Debug.Print "mymatid1"; mymatid1

    Exit_cmdNext_Click:
    Exit Sub

    Err_cmdNext_Click:
    MsgBox Err.Description
    Resume Exit_cmdNext_Click

    End Sub

    I have tested it a bit and it seems to work if you call it from within the form it is on but not if you call it from elsewhere.

    Here is how I call it
    Forms!frmEstimateComplete.Form!fsubEstDets!fsubMat sEst.Form.cmdNext_Click

  11. #11
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    my guess is you are moving the next record of current form, not the one you wanted.
    ghozy.

  12. #12
    Join Date
    Apr 2004
    Posts
    182
    Do you know of any way to do it from a form thats not the current one ?

  13. #13
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    I'm not sure but try this;
    Forms!frmEstimateComplete.Form!fsubEstDets!fsubMat sEst.Form.recordset.movenext
    ghozy.

  14. #14
    Join Date
    Apr 2004
    Posts
    182
    Quote Originally Posted by ghozy
    I'm not sure but try this;
    Forms!frmEstimateComplete.Form!fsubEstDets!fsubMat sEst.Form.recordset.movenext
    No I'm afraid not - Object does not support this property or method.

  15. #15
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    could you give the list of your forms, ordered by from parent to children?
    ghozy.

Posting Permissions

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