Exploding Continuous Subform

systemx

Registered User.
Local time
Tomorrow, 05:16
Joined
Mar 28, 2006
Messages
107
Hi all,

On my main form I have a continuous bound subform. The subform contains a small 'View' label next to each record.

The intention, is that when the user clicks on the 'View' label, another form is opened that previews some details for the current record.

Currently, for this to work correctly, the user must click somewhere in the corresponding subform record to 'select' the record.

Does anyone know of a way to automatically select the record, as soon as the label is clicked?

Happy to provide more info if needed.

Regards

Robert
 
Why not use a command button?
Anyways,
I have acomplished this in the past by:
In my continuous form, I add all the fields I want to display in my details form and hide them. Visible=false
I then create a new form that is not linked to any other form and with no recordsource. Add some unbound text boxes.
Now in the OnClick code of your label,
Create variables and copy the values of your hidden details to the variables, Open the new form, Copy the variables into the text boxes.

Onclick code:

Dim NotesVar As String
Dim DateRqstvar As String
Dim needbydatevar As String

If IsNull(Forms!F_rqst_picker!Notes) Then
NotesVar = ""
Else
NotesVar = Forms!F_rqst_picker!Notes
End If

If IsNull(Forms!F_rqst_picker!DateRqst) Then
DateRqstvar = ""
Else
DateRqstvar = Forms!F_rqst_picker!DateRqst
End If

If IsNull(Forms!F_rqst_picker!NeedByDate) Then
needbydatevar = ""
Else
needbydatevar = Forms!F_rqst_picker!NeedByDate
End If

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "F_Rqst_picker_notes"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Forms!F_rqst_picker_notes!Text1 = NotesVar
Forms!F_rqst_picker_notes!Text5 = DateRqstvar
Forms!F_rqst_picker_notes!Text7 = needbydatevar
 
Im searching for something similar...did that help system?
 
As long as the button is in the detail section of the subform with the record, clicking the button should put focus to that record. For instance, I've got this:

Code:
  Dim stDocName As String
  Dim stLinkCriteria As String

  stDocName = "frmEditRes"
  stLinkCriteria = "[res_num]=" & Me.res_num

  DoCmd.OpenForm stDocName, , , stLinkCriteria
 
Paul,

I'm leaving work now, but I'll be in tomorrow and hopefully I can get in touch with you to mess around with this. Thanks for the post.

Josh
 
Hi all,

Both of the above examples will work well. I am now using a command button, which works well.

What I originally tried playing around with was a mousedown event on a label - the form remains open as long as the user holds the mouse button down, then closes on the mouseup event.

When using this method, the record does not update - I assume because the focus is not set to the current record until the 'click' event completes (after the mouseup has been fired and form has closed).

I tried to get around this using instead of a label, a textbox control that was bound to my record ID. I simply coloured it in (font and background same colour) to look more like a button.

Only problem with this method, although the form opens correctly - the 'mouseup' event does not fire - so the form must be manually closed.

Here's what I was using -

Mouseup and Mousedown events on txtView (bound control, record ID) which is on the continuous subform -

Code:
Private Sub txtView_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

DoCmd.OpenForm "frmPrepPreview"

End Sub

Code:
Private Sub txtView_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

If IsOpen("frmPrepPreview") Then
    DoCmd.Close acForm, "frmPrepPreview", acSaveNo
Else
    Exit Sub
End If

End Sub

Form Load event for my exploding form -

Code:
Private Sub Form_Load()

Dim intEnq As Integer

'N.B. Flawed, user must select row of continuous form for this to work
intEnq = Int(Forms!frmPreparation.subPreparation.Form.txtView.Value)

Dim strDescription As String
Dim strOutcome As String

strDescription = DLookup("Description", "tblEnquiries", "[ID]=" & intEnq)
If IsNull(strDescription) Then
strDescription = "No description was entered for this enquiry"
End If

strOutcome = DLookup("Customer_Outcome", "tblEnquiries", "[ID]=" & intEnq)
If IsNull(strOutcome) Then
strOutcome = "No customer outcome was entered for this enquiry"
End If

Me.lblDescription.Caption = strDescription
Me.lblOutcome.Caption = strOutcome

End Sub

If anyone knows why the mouseup event does not seem to be firing on my textbox control - I would be interested to find out why!

Cheers,

Rob
 

Users who are viewing this thread

Back
Top Bottom