Really basic question - easiest way to just display ONE record from a table?

  • Thread starter Thread starter Angus Comber
  • Start date Start date
A

Angus Comber

Hello

I want to display just one row from a table.

Eg: SELECT * FROM Table1 WHERE xyzID = SomeValue

I can do it all in code but am hoping because it is Access I can maybe do it
with limited code?

Eg on one form I have the SomeValue - want to then in OnClick Event pass
SomeValue to say a query to get data for form?

Hope I am explaining myself ok.

How do I do that?

Form will be standard fields - eg text fields displaying row data.

Angus
 
Angus said:
Hello

I want to display just one row from a table.

Eg: SELECT * FROM Table1 WHERE xyzID = SomeValue

I can do it all in code but am hoping because it is Access I can
maybe do it with limited code?

Eg on one form I have the SomeValue - want to then in OnClick Event
pass SomeValue to say a query to get data for form?

Hope I am explaining myself ok.

How do I do that?

Form will be standard fields - eg text fields displaying row data.

Angus

Drop a new button onto your form in design view making sure that the toolbox
wizard is enabled. One of the wizard options for opening a form with a
button will do exactly what you want.
 
Angus,

To use the current record as a filter for opening a second form, pass the
value to the Where parameter of the Openform method. This is most easily
done by enabling the wizard. From form design view, choose View, Toolbox,
then toggle on the button with the wand and stars. Then place a command
button, and the wizard will guide you through. Select the form, choose "Open
With Selected Data", and identify the controls on each form that have the
matching data. The wizard will generate code similar to this:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourSecondForm"

stLinkCriteria = "[FieldOn2ndForm]=" & Me![ControlOn1stForm]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Hope that helps.
Sprinks
 
definitely. that was what I need. I come from a coding background so
trying to adjust to use code as little as possible for productivity with
Access now.


Sprinks said:
Angus,

To use the current record as a filter for opening a second form, pass the
value to the Where parameter of the Openform method. This is most easily
done by enabling the wizard. From form design view, choose View, Toolbox,
then toggle on the button with the wand and stars. Then place a command
button, and the wizard will guide you through. Select the form, choose "Open
With Selected Data", and identify the controls on each form that have the
matching data. The wizard will generate code similar to this:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourSecondForm"

stLinkCriteria = "[FieldOn2ndForm]=" & Me![ControlOn1stForm]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Hope that helps.
Sprinks

Angus Comber said:
Hello

I want to display just one row from a table.

Eg: SELECT * FROM Table1 WHERE xyzID = SomeValue

I can do it all in code but am hoping because it is Access I can maybe do it
with limited code?

Eg on one form I have the SomeValue - want to then in OnClick Event pass
SomeValue to say a query to get data for form?

Hope I am explaining myself ok.

How do I do that?

Form will be standard fields - eg text fields displaying row data.

Angus
 

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

Back
Top