Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2003
    Location
    Washington, DC
    Posts
    116

    Unanswered: Click text box to open form and locate record on subform

    I'm trying to create a click event on a text box that will open a form and dispaly the selected record. The problem I'm encountering is that the form that is being opened displays the selected record's data in a subform. Here is my code:

    Private Sub Description_Click()
    On Error GoTo Err_Description_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmAcquisition"

    stLinkCriteria = Me.sbfrmAcquisitionList.AcqID
    DoCmd.OpenForm stDocName, , , "[sbfrmAcquisitions].[AcqID] = " & stLinkCriteria

    Exit_Description_Click:
    Exit Sub

    Err_Description_Click:
    MsgBox Err.Description
    Resume Exit_Description_Click

    End Sub

  2. #2
    Join Date
    Jul 2005
    Posts
    144

    Question

    Quote Originally Posted by PatrickFAO
    I'm trying to create a click event on a text box that will open a form and dispaly the selected record. The problem I'm encountering is that the form that is being opened displays the selected record's data in a subform. Here is my code:

    Private Sub Description_Click()
    On Error GoTo Err_Description_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmAcquisition"

    stLinkCriteria = Me.sbfrmAcquisitionList.AcqID
    DoCmd.OpenForm stDocName, , , "[sbfrmAcquisitions].[AcqID] = " & stLinkCriteria

    Exit_Description_Click:
    Exit Sub

    Err_Description_Click:
    MsgBox Err.Description
    Resume Exit_Description_Click

    End Sub
    If i understand this correctly you want to open the main form with the desire record?

    but in your code you are telling it to open subform.
    or am i not seeing this correctly??

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    [sbfrmAcquisitions] would appear to be a subform to me also. BTW, is this text box actually used for data entry? If so, you'll probably want to use the double-click event rather than the click event. That way users can use the mouse to go to the field without triggering the form opening. If it's not used for data entry, but just to trigger this event, why not use a label? They have click events, also.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Join Date
    Sep 2003
    Location
    Washington, DC
    Posts
    116
    The primary form is one that list the acquisitions for a particular investment. You cannot edit the information from this form. You can only sort the records and click on each record to retrieve the details about it. The calling of the details is what I'm struggling with.

    When you click on the text box the code should retrieve the AcqID, and open another form called frmAcquisition. This form has sbfrmAcquisitions, which is where the detail for the AcqID shows up.

    Does this help?

  5. #5
    Join Date
    Jul 2005
    Posts
    144

    Wink

    Quote Originally Posted by PatrickFAO
    The primary form is one that list the acquisitions for a particular investment. You cannot edit the information from this form. You can only sort the records and click on each record to retrieve the details about it. The calling of the details is what I'm struggling with.

    When you click on the text box the code should retrieve the AcqID, and open another form called frmAcquisition. This form has sbfrmAcquisitions, which is where the detail for the AcqID shows up.

    Does this help?
    then why not use a combobox on a main form and have it connected to subform by linking child and master fields. And you can restriced access to read only.

Posting Permissions

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