Access "Time & Billing" Template / Timecard Problems

R

Robi

=DLookUp("[FirstName]","Employees",[EmployeeID]=Forms![Time
Cards]!EmployeeID) & " " &
DLookUp("[LastName]","Employees",[EmployeeID]=Forms![Time Cards]!EmployeeID)

The above is the expressions that is shown in the area of the timecard that
is not working correctly... Could xomeone direct me to a solution on how to
fix my Access Time and Billing Template (Timecard).

Thank you.
Robi
 
D

Douglas J. Steele

The 3rd parameter of the DLookup is supposed to be string that represents a
WHERE clause (without the keyword WHERE). As well, it's a little-known fact
that you can actually return more than one value at a time using DLookup.

See whether this works any better:

=DLookUp("[FirstName] & ' ' & [LastName]","Employees", "[EmployeeID]=" &
Forms![Time Cards]!EmployeeID)
 
J

Jeff Conrad

I see what you mean Robi. Not exactly "helpful' is it?

Lots of ways to do this, but here is one easy way.

1. I don't like the fact that you can click in that box.
Right click on that text box and go to Properties. Set these:
Enabled = No
Locked = Yes

2. Delete everything in the Control Source so it is unbound.

3. Now assuming you want to keep the name of that text box
as Text14 (ugh...) go to the Current event of the *form* and
find this code:

Private Sub Form_Current()
If IsNull(Me![TimeCardID]) Then
DoCmd.GoToControl "EmployeeID"
End If
End Sub

Add a few more lines of code so it now looks like this:

Private Sub Form_Current()
If IsNull(Me![TimeCardID]) Then
DoCmd.GoToControl "EmployeeID"
End If
If IsNull(Me.EmployeeID) Then
Me.Text14 = "<New Timecard>"
Else
Me.Text14 = Me.EmployeeID.Column(1)
End If
End Sub

4. Compile the code, save and close the form.
Then test it. The box should display the current person's name.
Going to a new record will display <New Timecard>
You can change that to something else if you prefer.

Hope that helps,
--
Jeff Conrad
Access Junkie - MVP
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html

in message:
 
R

Robi

Doug,

That was it!!! Thanks to you, I'll be able to meet my deadline... :D Thank
you so much, and HAPPY NEW YEAR!!! xxx

Robi



Douglas J. Steele said:
The 3rd parameter of the DLookup is supposed to be string that represents a
WHERE clause (without the keyword WHERE). As well, it's a little-known fact
that you can actually return more than one value at a time using DLookup.

See whether this works any better:

=DLookUp("[FirstName] & ' ' & [LastName]","Employees", "[EmployeeID]=" &
Forms![Time Cards]!EmployeeID)


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Robi said:
=DLookUp("[FirstName]","Employees",[EmployeeID]=Forms![Time
Cards]!EmployeeID) & " " &
DLookUp("[LastName]","Employees",[EmployeeID]=Forms![Time
Cards]!EmployeeID)

The above is the expressions that is shown in the area of the timecard
that
is not working correctly... Could xomeone direct me to a solution on how
to
fix my Access Time and Billing Template (Timecard).

Thank you.
Robi
 

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