queries and multiple form instances

  • Thread starter Thread starter Miranda
  • Start date Start date
M

Miranda

hi,

i've got a query something like

SELECT MaterialsAssigned.material
FROM MaterialsAssigned
WHERE MaterialsAssigned.jobDesc= form!dataEntryForm!jobdesc;

i've recently changed the dataEntryForm so it can have multiple instances
opened. so i can no longer refer to it as form!dataentryForm!...i'm using
the hwnd to reference the forms. so all the queries that the form relies on
no longer work (they are used to populate drop down boxes).

does anyone know how i can refer to these forms in my queries ?

any help would be appreciated!

by the way i'm setting the text box jobdesc on my dataEntryForm using a
global variable - don't know if this helps?
 
If you want each instance to refer to a different JobDesc value, the
simplest approach might be to place an unbound text box on the form itself,
and use its AfterUpdate event to set the RecordSource of that form instance.

Set the RecordSource of the form so that it initially loads no records:
SELECT MaterialsAssigned.material
FROM MaterialsAssigned
WHERE (False);

Then in the AfterUpdate event procedure of txtJobDesc:

Private Sub txtJobDesc_AfterUpdate()
Dim strWhere As String

If Me.Dirty Then
Me.Dirty = False
End If

If IsNull(Me.txtJobDesc) Then
strWhere = "(False)"
Else
strWhere = "MaterialsAssigned.jobDesc = " & Me.txtJobDesc
End If

Me.RecordSource = " SELECT MaterialsAssigned.material FROM
MaterialsAssigned WHERE " & strWhere & ";"
End Sub
 
Back
Top