open form with certain records

human_anomaly

Registered User.
Local time
Today, 10:18
Joined
Apr 12, 2004
Messages
69
Here is the problem, I have a table with student names in it (as a primary key) there is another table that contains the students data. In this data table the students name is also listed, but not as a primary key, so there are many copies of a single name. What I am trying to do is open a form with the students name, but only for the students that have data. I was thinking about using Dlookup or creating a query of student names from the data table using something like a SELECT DISTINCT clause. I know I'm on the right path I just can put it all together this late in the day. Can anyone give me an idea or example of how to do this?
 
got it working

I got it working, I just created a simple query of the student field in the data table. Then I right clicked on the item in the query design view and selected properties. I then saw a check box for SELECT DISTINCT. I checked it and it seems to be doing exaclty what I wanted. The funny thing is that I just stumbled upon it, I didn't even know that you could go to the properties of a query record.
 
Try pasting this code in a command button (on click event).

On Error GoTo Err_Handler

Dim strFieldName As String
Dim strForm As String

strForm = "Form Name that you wish to open"
'Open a form with specific record
strFieldName = "[FieldName]='" & Me.FieldName & "'"

DoCmd.OpenForm strForm, , , strFieldName

Exit_Here:
Exit Sub

Err_Handler:
MsgBox Err.Description & " " & Err.Number
Resume Exit_Here
End Sub


hth,

Michael
 

Users who are viewing this thread

Back
Top Bottom