Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Feb 2002
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Button Code (A2K)

    I have the following code on a button on my main form.

    Private Sub Command276_Click()


    On Error GoTo Err_Command276_Click
    Dim qus As Integer

    EstimateNo.SetFocus
    qus = MsgBox("Create Supp Record " & DMax("SUPP", "tbldetails", "[estimateno] = estimateno.Text") + 1 & " For Estimate " & EstimateNo.Text, vbYesNo, "New Record")
    If qus = 6 Then
    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
    EstimateNo.SetFocus
    Me.supp = DMax("SUPP", "tbldetails", "[estimateno] = estimateno.Text") + 1
    Forms!FRMDETAILS.Refresh
    End If

    Exit_Command276_Click:
    Exit Sub

    Err_Command276_Click:
    MsgBox Err.Description
    Resume Exit_Command276_Click

    End Sub

    The button messes up my main form so I want to move it to another.
    A2K
    Mainform = frmDetails
    Form I want to move it to= frmSideMenu.

    I can't get it to work can some-one help.

    Dave

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Button Code (A2K)

    I would really help if you could let us know what the code is supposed to do and what kind of failure you are getting, because the sentence "really messes up on my mainform" isn't much of a help. Also, you should really get away from using the DoMenuItem. Use RunCommand instead; one valuable feature is that the RunCommand constants are in readable English, such as:

    RunCommand acCmdDeleteRecord

    No doubt about what that is for!
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Star Lounger
    Join Date
    Feb 2002
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Button Code (A2K)

    By messing up my ainform, I am trying to create my DB with as little mouse usage as possible. This button ls situated on my mainform and looks untidy.
    It needs to go on another Menu form. The code works ok on the main because of its record source.
    Does this help any.
    Dave

  4. #4
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Button Code (A2K)

    >>By messing up my ainform, I am trying to create my DB with as little mouse usage as possible. This button ls situated on my mainform and looks untidy.
    It needs to go on another Menu form. The code works ok on the main because of its record source.
    Does this help any.<<

    Not really. I still don't know what you are trying to do with this code. What are all the DoMenuItems for? If it is trying to delete a record or duplicate a record, or whatever, it will only work if the form containing the record has the focus. Which means to run it from some other form, the first form must be open and positioned at the record you want, the you have to move focus from the other form to the main form containing the record.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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