Open form then populate form with data

ScrmingWhisprs

I <3 Coffee Milk.
Local time
Today, 06:36
Joined
Jun 29, 2006
Messages
156
This one is really bugging me and I can figure it out for the life of me.

I have a form (frmSelect) that can be opened from different forms that acts as a code selection form. I have an unbound listbox and 2 textboxes that are hidden (txtForm and txtControl). On another form I have on the Double Click Event of a textbox this code:

Code:
Private Sub ReportType_DblClick(Cancel As Integer)
    
Dim strSQL As String

strSQL = "SELECT [tblReportTypes].[ID], [tblReportTypes].[ReportType] FROM [tblReportTypes] ORDER BY [ID];"
    
    DoCmd.OpenForm "frmSelect", acNormal, , , , acDialog
    Forms!frmSelect!txtForm = Me.Name
    Forms!frmSelect!txtControl = "ReportType"   
    Forms!frmSelect!lboSelect.Rowsource = strSQL

End Sub

So here's what happens on the Double Click Event: The form (frmSelect) opens. The listbox and the 2 textboxes do not populate. When I close the form, I get a runtime error 2450: can't find the form 'frmSelect'.

I don't know what I'm doing wrong...

Thanks
 
What you are doing wrong is trying to refer to the form that is closed:

Forms!frmSelect!txtForm = Me.Name
Forms!frmSelect!txtControl = "ReportType"
Forms!frmSelect!lboSelect.Rowsource = strSQL

The code:
DoCmd.OpenForm "frmSelect", acNormal, , , , acDialog

opens the form but the acDialog stops it right there and does not continue until you close the form.
 
You would need to move the code (changing it to refer to the right form references, of course) from this event to the LOAD event of the frmSelect form.
 
Coolness. I removed the acdialog now it's working perfectly!

Thank you so much!!! I would have never figured out that one little thing was stopping it.
 

Users who are viewing this thread

Back
Top Bottom