Default staff number to current

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have placed an option on an employee form to view other records related to
employees from another table. The query uses a parameter box to prompt the
user for a staff number.

What I want to do is default the staff number to the employee who's form is
currently in view. How difficult is this to do?
 
NoviceIan said:
I have placed an option on an employee form to view other records
related to employees from another table. The query uses a parameter
box to prompt the user for a staff number.

What I want to do is default the staff number to the employee who's
form is currently in view. How difficult is this to do?

One of the wizard options for a new command button does exactly this. It uses
the optional WHERE argument for the OpenForm method to filter the form being
opened to match a control on the calling form.
 
Would that be an event procedure? If so is there any other way i could do
this using a macro because I have the Has Module property set to No on this
form and would prefer to keep it that way. However if theres no other way or
the other way is too difficult then I'll try that.
 
NoviceIan said:
Would that be an event procedure? If so is there any other way i
could do this using a macro because I have the Has Module property
set to No on this form and would prefer to keep it that way. However
if theres no other way or the other way is too difficult then I'll
try that.

There is likely a similar way to do it with a Macro, but I am not familiar with
them as I never use them and the wizard will not build it for you as a Macro.

The advantages of HasModule = No are slim and none. I wouldn't let that stand
in the way of doing things properly.
 
Ok so how to I do it? I checked out the create button and assigning the
query to it but I did'nt see where I could solve my problem.
 
NoviceIan said:
Ok so how to I do it? I checked out the create button and assigning
the query to it but I did'nt see where I could solve my problem.

The command button wizard (in Access 97)...

Form Operations - Open Form
Select Form to Open
"Open the form and find specific data to display"
Select fields that contain matching data
Next, Next , Finish
 
Sorry I'm not getting this. Basically the form which houses the option is a
staff details form. The option finds all mileage claims relating to any
employee using a parameter box from the query. Sorry I'm not much good at
this.
 
NoviceIan said:
Sorry I'm not getting this. Basically the form which houses the
option is a staff details form. The option finds all mileage claims
relating to any employee using a parameter box from the query. Sorry
I'm not much good at this.

You would eliminate the parameter box in the query. By using the Where clause
in the OpenForm event it is not needed.

Simple example: If first form and second form both had numeric fields named
EmployeeID...

DoCmd.OpenForm "MileageClaims",,,"EmployeeID = " & Me.EmployeeID

The above says "open the form named "MileageClaims" filtered where the field
EmployeeID is equal to the EmployeeID on the current form".
 
Back
Top