From: Amanda on
I'm new to access. I would like to put a command button to print a selected
record buy it asking me what record # do you want to print. I can't seem to
get this to work. Thank you in advance.
From: Klatuu on
What do you mean by record number? There are no record numbers in Access.
If you mean the number you see in the box between the navigation buttons on
a form, those numbers just represent the ordinal position of the record
within the form's current recordset. They cannot be depended on. Any time
you filter a form, add a record, delete a record, or change the form's order,
the number will change. Normally, you would want to use some unique field in
the form's recordset to indentify a record. Then you can use the Where
argument of the OpenReport method to filter the report to that one record.
For example, say you have a customer form and the customer table has a
CustomerID primary key field, it would be:

Docmd.OpenReport "CustomerReport", , , "[CustomerID] = " &
Me.txtCustomerID

--
Dave Hargis, Microsoft Access MVP


"Amanda" wrote:

> I'm new to access. I would like to put a command button to print a selected
> record buy it asking me what record # do you want to print. I can't seem to
> get this to work. Thank you in advance.
From: Amanda on
We use record # for the primary key field. Sorry

"Klatuu" wrote:

> What do you mean by record number? There are no record numbers in Access.
> If you mean the number you see in the box between the navigation buttons on
> a form, those numbers just represent the ordinal position of the record
> within the form's current recordset. They cannot be depended on. Any time
> you filter a form, add a record, delete a record, or change the form's order,
> the number will change. Normally, you would want to use some unique field in
> the form's recordset to indentify a record. Then you can use the Where
> argument of the OpenReport method to filter the report to that one record.
> For example, say you have a customer form and the customer table has a
> CustomerID primary key field, it would be:
>
> Docmd.OpenReport "CustomerReport", , , "[CustomerID] = " &
> Me.txtCustomerID
>
> --
> Dave Hargis, Microsoft Access MVP
>
>
> "Amanda" wrote:
>
> > I'm new to access. I would like to put a command button to print a selected
> > record buy it asking me what record # do you want to print. I can't seem to
> > get this to work. Thank you in advance.
From: Klatuu on
Okay.

Dim txtRecordNbr As txt

txtRecordNbr = InputBox("Enter Record # To Print")
If txtRecordNbr <> vbNullString Then
Docmd.OpenReport "CustomerReport", , , "[Record #] = " &
Clng(txtRecordNbr)
End If


--
Dave Hargis, Microsoft Access MVP


"Amanda" wrote:

> We use record # for the primary key field. Sorry
>
> "Klatuu" wrote:
>
> > What do you mean by record number? There are no record numbers in Access.
> > If you mean the number you see in the box between the navigation buttons on
> > a form, those numbers just represent the ordinal position of the record
> > within the form's current recordset. They cannot be depended on. Any time
> > you filter a form, add a record, delete a record, or change the form's order,
> > the number will change. Normally, you would want to use some unique field in
> > the form's recordset to indentify a record. Then you can use the Where
> > argument of the OpenReport method to filter the report to that one record.
> > For example, say you have a customer form and the customer table has a
> > CustomerID primary key field, it would be:
> >
> > Docmd.OpenReport "CustomerReport", , , "[CustomerID] = " &
> > Me.txtCustomerID
> >
> > --
> > Dave Hargis, Microsoft Access MVP
> >
> >
> > "Amanda" wrote:
> >
> > > I'm new to access. I would like to put a command button to print a selected
> > > record buy it asking me what record # do you want to print. I can't seem to
> > > get this to work. Thank you in advance.
From: Amanda on
Thank you I will try this. Have a great weekend!

"Klatuu" wrote:

> Okay.
>
> Dim txtRecordNbr As txt
>
> txtRecordNbr = InputBox("Enter Record # To Print")
> If txtRecordNbr <> vbNullString Then
> Docmd.OpenReport "CustomerReport", , , "[Record #] = " &
> Clng(txtRecordNbr)
> End If
>
>
> --
> Dave Hargis, Microsoft Access MVP
>
>
> "Amanda" wrote:
>
> > We use record # for the primary key field. Sorry
> >
> > "Klatuu" wrote:
> >
> > > What do you mean by record number? There are no record numbers in Access.
> > > If you mean the number you see in the box between the navigation buttons on
> > > a form, those numbers just represent the ordinal position of the record
> > > within the form's current recordset. They cannot be depended on. Any time
> > > you filter a form, add a record, delete a record, or change the form's order,
> > > the number will change. Normally, you would want to use some unique field in
> > > the form's recordset to indentify a record. Then you can use the Where
> > > argument of the OpenReport method to filter the report to that one record.
> > > For example, say you have a customer form and the customer table has a
> > > CustomerID primary key field, it would be:
> > >
> > > Docmd.OpenReport "CustomerReport", , , "[CustomerID] = " &
> > > Me.txtCustomerID
> > >
> > > --
> > > Dave Hargis, Microsoft Access MVP
> > >
> > >
> > > "Amanda" wrote:
> > >
> > > > I'm new to access. I would like to put a command button to print a selected
> > > > record buy it asking me what record # do you want to print. I can't seem to
> > > > get this to work. Thank you in advance.
 |  Next  |  Last
Pages: 1 2
Prev: Access 2003 - Command Button
Next: Yearly calender