Access 2003 - Command Button

M

Marsh

A database we use in Access 2003 has a form named frmJobInfo. It is a large
form, with many fields, date and time picker contros, unbound controls with
formulas built-in, etc. This form contains fields necessary for our customer
service reps to be able enter a width and depth to calculate cost factors, in
the form. These functions work perfectly. Several of the fields are
TrackingNum, ReqName, DateSubmit, DateDue, and others that completely define
and describe the job, including the width and depth.
I would like to create a form in Datasheet view that displays all active
jobs, with fields TrackingNum, ReqName, DateSubmit, DateDue so that a user
can pick out a job that needs attention. That I can do. What I would then
like to do is have some sort of clickable control so that when clicked, it
will open the form, frmJobInf, with the desired job data displayed in the
form. In a perfect world, making the TrackingNum field in the datasheet form
a clickable “action or command button†would be a perfect solution. In that
way, the correct job is displayed in frmJobInfo without the necessity of
typing the tracking number.
Thank you for any aid.
 
D

Dirk Goldgar

Marsh said:
A database we use in Access 2003 has a form named frmJobInfo. It is a
large
form, with many fields, date and time picker contros, unbound controls
with
formulas built-in, etc. This form contains fields necessary for our
customer
service reps to be able enter a width and depth to calculate cost factors,
in
the form. These functions work perfectly. Several of the fields are
TrackingNum, ReqName, DateSubmit, DateDue, and others that completely
define
and describe the job, including the width and depth.
I would like to create a form in Datasheet view that displays all active
jobs, with fields TrackingNum, ReqName, DateSubmit, DateDue so that a user
can pick out a job that needs attention. That I can do. What I would
then
like to do is have some sort of clickable control so that when clicked, it
will open the form, frmJobInf, with the desired job data displayed in the
form. In a perfect world, making the TrackingNum field in the datasheet
form
a clickable “action or command button†would be a perfect solution. In
that
way, the correct job is displayed in frmJobInfo without the necessity of
typing the tracking number.
Thank you for any aid.


Normally I'd use the DblClick event for this sort of thing, but if your
datasheet form is used only to choose the job, never to edit it, you might
use the Click event as you were thinking. So your code for the Click event
of the TrackingNum text box might look like this:

'----- start of example code -----
Private Sub TrackingNum_Click()

If Not IsNull(Me.TrackingNum) Then
DoCmd.OpenForm "frmJobInf", _
WhereCondition:="TrackingNum=" & Me.TrackingNum
End If

End Sub
'----- end of example code -----

That assumes that TrackingNum is a numeric field. If it's text, but won't
ever contain the single-quote (or apostrophe) character, then you'd modify
the WhereCondition argument accordingly:

WhereCondition:="TrackingNum='" & Me.TrackingNum & "'"

If it might contain the single-quote character, there are other forms for
the argument. Let me know.
 
M

Marsh

Thank you Dirk.
The datasheet will be only to choose the record, single click will suffice.
I will let you know how I make out.
 
M

Marsh

I was out of work, ill, so I just got back to this project.

Worked perfectly, thank you very much.
 

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