display a record in a form

andyswinburne

Registered User.
Local time
Today, 15:32
Joined
Sep 29, 2003
Messages
22
All i want to know is given the ID (primary key) of a record within a table, how can i display this (and only this) record on the associated form. Sure it is simple but i'm stuck and getting no where

cheers

Andy Swinburne
 
1. Set the Forms Filter property to only display the record.
Example
[ID Field Name]=ID#

2. Create a RecordSet Object and Set the forms RecordSet Propery equal to the RecordSet Object.

3. Create a Form to select the ID# and use the Docmd.OpenForm function setting the [Where] options equal to [ID Field Name]=ID#
 
a couple of questions for part 1

do you mean using the form filter as in:

Me.Filter = "[BowlerID] = ID"
Me.FilterOn = True

This is basically what i want to do, so it is more like a search for a record by the ID rather than a filter as it will only return one record, but this filter only works with strings so i cant use it for ID?

and for part 2

I dont really know how to work record sets i've tried using them breifly from others examples but don't seem to work, should i declare them in any particular part?

thank you
 
Think about the logic.

You want to show the record based on a user supplied ID. So you need three things:
1) A form to display the data in
2) A way of getting the user input
3) A way of locating the relevant record

The simplest way is the base the form on a parameter query. When you open the form the parameter query will prompt the user for input, run the query and populate the form.

Does this help?
 
Me.Filter = "[BowlerID] = ID"
Me.FilterOn = True

This is basically what i want to do, so it is more like a search for a record by the ID rather than a filter as it will only return one record, but this filter only works with strings so i cant use it for ID?

I do not know what you base this on, but I have used many different types of variables (Boolean, String, and Numbers). The Filter property is a string value, but think of it more as the Where/Having clause in an SQL statement. The same rules apply.
 
Problem solved, i just ran the query i created that displayed the correct field and then used the auto form to show this record.

It doesn't open it in the form i wanted but it'll do the job and saves trying to use the filter which wasn't working.

thanks anyway

andy
 
You are probably usint the OpenForm method to open the form so, use the where argument of the OpenForm method to supply the criteria for a form's recordsource query.
 

Users who are viewing this thread

Back
Top Bottom