Results 1 to 6 of 6
  1. #1
    Join Date
    May 2004
    Posts
    63

    Question Unanswered: Help with Cmd button

    I have wrote following code to open "frmOrder" from "frmCustomer". This code wrok fine when i had my command button in "frmCustomer" detail. But when i move the cmdbutton in the Form Header it doesn't wrk and i can't figure it out why ?

    Private Sub cmdOrder_Click()

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmOrder"

    stLinkCriteria = "[tblCustomer.cutomerID]=" & Me![CustomerID]
    If IsDataValid Then

    DoCmd.OpenForm stDocName, , , , , , "CallingForm:frmCustomer"
    Forms!frmVisit.cboSelectMother = Me.txtCustomerID
    DoCmd.Close acForm, "frmCustomer"

    End If

    End Sub

  2. #2
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    DoCmd.OpenForm stDocName, , , , , , "CallingForm:frmCustomer"


    ^^ I see opens the frmOrder, but what does the end of that do? I dont understand is that somekind of a filter?

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    i guess you want to go back to whichever was the calling form.

    "it doesn't work" is not much of a description... do you want to add some detail?

    izy
    currently using SS 2008R2

  4. #4
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004
    Hi SAK2004,
    Here is the code behind my CommandButton. Compare. I can't understand what your other lines are doing but have a look anyway.
    Code:
    Private Sub cmbCancelledJobs_Click()
    On Error GoTo Err_cmbCancelledJobs_Click
    'Created by "Bud".
    'Opens the OrderStatusCancellation form to show all orders that
    'are cancelled by the Vendor the user is now viewing.
    
        Dim stDocName As String
        Dim stLinkCriteria As String
    
        stDocName = "frmOrderStatusCancellation"
        
        stLinkCriteria = "[VendorID]=" & Me![VendorID]
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    
    Exit_cmbCancelledJobs_Click:
        Exit Sub
    
    Err_cmbCancelledJobs_Click:
        MsgBox Err.Description
        Resume Exit_cmbCancelledJobs_Click
        
    End Sub
    Now having pasted that here I paid closer attention to your real problem. Try creating the entire CommandButton again, but in the Header. Not sure if there should be a reason why it won't work there, but have them in the footer so it should be the same.
    Bud

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    hmmm,

    o we have a divergence of opinion concerning the required number of ","

    o the original post creates stlinkcriteria, but doesn't use them

    o ...and no, the button doesn't care where it is.

    izy
    currently using SS 2008R2

  6. #6
    Join Date
    May 2004
    Posts
    63

    Thumbs up

    I created new command button in form header using same code and now its works fine.

    Thanks all of you for your response.

Posting Permissions

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