Open Form based on Multiple Values from Query

I

ifcgroup

The recordset basically brings up all the LTable.LDDRNumbers where my
username is equal to either the BEMS field's username or the
ManagerBEMS field's username. Then, I want to open up a form that
pulls up only those LDDR Numbers that are in the recordset. Using
queryResults!LDDRNumber obviously only gives me the first record so
the form only opens with one record. How can I make it open with all
the records?


LTable has a primary key LDDRNumber
has a field BEMS which is a foreign key(BEMS) from the UsersTable
has another field ManagerBEMS which is a foreign key(BEMS) from
the UsersTable

UsersTable has a primary key BEMS and another field username


Dim db As DAO.Database
Dim queryResults As DAO.Recordset
Dim queryString As String
Dim filterString As String
Set db = CurrentDb

queryString = "SELECT LTable.LDDRNumber, UsersTable.Username,
UsersTable_1.Username FROM (LTable INNER JOIN UsersTable ON
LTable.ManagerBEMS = UsersTable.BEMS) INNER JOIN UsersTable AS
UsersTable_1 ON LTable.BEMS = UsersTable_1.BEMS WHERE
(((UsersTable.Username)=CurrentUser())) OR
(((UsersTable_1.Username)=CurrentUser()));"

Set queryResults = db.OpenRecordset(queryString)
filterString = queryResults!LDDRNumber

If queryResults.recordCount = 0 Then
MsgBox "There are no LDDRs for you to complete or sign."
Else
DoCmd.OpenForm "LDDRsNew-initiate", acNormal, , "LDDRNumber =
" & queryString
End If
 
M

Matt

One way to do it would be to add a Subform based on the query. Have the
Subform default display be "datasheet view". This would display all results
 
I

ifcgroup

I'm not sure I understand ... the queryResults recordset returns the
correct primarykeys (LDDRNumber)... but then I want to open up a form
with just those records. The subform would just show the values of
queryResults. I guess I think there has to be some way to create a
filter or a where condition based on the values in the queryResults
recordset. If there's not a way, then I'll try to figure out a
different solution.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top