Open Form Based on Recordset Results

I

ifcgroup

I also posted this in microsoft.public.access.forms:

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
 

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