DLookUp Problem

L

lilbit27

I have a Mainform called "MainPastDue" and a Subform called "PastDues".
Currently when the user logs in they open the Mainform and click on an
Option button and a combo box appears where they can select their name
and it will filter the data in the subform based on there name.

I wanted to automate this process.

I created a table that stores their "ComputerName" and the uers name.
What I would like to happen is to take the computer name look up the
user's name that maps to the computer name and when they click on
option one filter the data automatically to show only their items
instead of them having to select their name.

Here is the code on the Afterupdate of Option 1:

Dim linker
Dim strSQL As String
linker = Frame95.Value
Select Case linker
Case 0
ittype = 0
Me.Cmdclose.SetFocus
Me.FPastDues.Form.FilterOn = False
strSQL = "TARA.NetC=0"
FPastDues.Visible = True
Me.FPastDues.Form.Filter = strSQL
Me.FPastDues.Form.FilterOn = True

What I am trying to add is this:

Me.CboName = DLookup("[EmployeeName]", "TShortNames", "[ShortName] =
FOSUserName()")

Me.CboName - is the combo box where they currently select their name.
TshortNames -is the table that stores the computer name and their name
FOSUserName- is the function I am using to capture the computer name

The Mainform and Subform record source is using another table that has
the empolyee's name and I need to somehow say after it finds the
Employee name match it to name int he main table and refilter the info.
 
L

lilbit27

I get an error that says you canceled the previous expression.
Your Dlookup look wrong. Try

Me.CboName = DLookup("[EmployeeName]", "TShortNames", "[ShortName] =" &
FOSUserName())

Daniel





lilbit27 said:
I have a Mainform called "MainPastDue" and a Subform called "PastDues".
Currently when the user logs in they open the Mainform and click on an
Option button and a combo box appears where they can select their name
and it will filter the data in the subform based on there name.

I wanted to automate this process.

I created a table that stores their "ComputerName" and the uers name.
What I would like to happen is to take the computer name look up the
user's name that maps to the computer name and when they click on
option one filter the data automatically to show only their items
instead of them having to select their name.

Here is the code on the Afterupdate of Option 1:

Dim linker
Dim strSQL As String
linker = Frame95.Value
Select Case linker
Case 0
ittype = 0
Me.Cmdclose.SetFocus
Me.FPastDues.Form.FilterOn = False
strSQL = "TARA.NetC=0"
FPastDues.Visible = True
Me.FPastDues.Form.Filter = strSQL
Me.FPastDues.Form.FilterOn = True

What I am trying to add is this:

Me.CboName = DLookup("[EmployeeName]", "TShortNames", "[ShortName] =
FOSUserName()")

Me.CboName - is the combo box where they currently select their name.
TshortNames -is the table that stores the computer name and their name
FOSUserName- is the function I am using to capture the computer name

The Mainform and Subform record source is using another table that has
the empolyee's name and I need to somehow say after it finds the
Employee name match it to name int he main table and refilter the info.
 
D

Douglas J. Steele

That very misleading message generally means you mistyped either a field
name, or the name of the table.

BTW, Daniel made a slight mistake in what he gave you.

Since fOSUserName returns a string, you need quotes around it:

Me.CboName = DLookup("[EmployeeName]", "TShortNames", _
"[ShortName] ='" & fOSUserName() & "'")

Exagerated for clarity, that's


Me.CboName = DLookup("[EmployeeName]", "TShortNames", _
"[ShortName] = ' " & fOSUserName() & " ' ")

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


lilbit27 said:
I get an error that says you canceled the previous expression.
Your Dlookup look wrong. Try

Me.CboName = DLookup("[EmployeeName]", "TShortNames", "[ShortName] =" &
FOSUserName())

Daniel





lilbit27 said:
I have a Mainform called "MainPastDue" and a Subform called "PastDues".
Currently when the user logs in they open the Mainform and click on an
Option button and a combo box appears where they can select their name
and it will filter the data in the subform based on there name.

I wanted to automate this process.

I created a table that stores their "ComputerName" and the uers name.
What I would like to happen is to take the computer name look up the
user's name that maps to the computer name and when they click on
option one filter the data automatically to show only their items
instead of them having to select their name.

Here is the code on the Afterupdate of Option 1:

Dim linker
Dim strSQL As String
linker = Frame95.Value
Select Case linker
Case 0
ittype = 0
Me.Cmdclose.SetFocus
Me.FPastDues.Form.FilterOn = False
strSQL = "TARA.NetC=0"
FPastDues.Visible = True
Me.FPastDues.Form.Filter = strSQL
Me.FPastDues.Form.FilterOn = True

What I am trying to add is this:

Me.CboName = DLookup("[EmployeeName]", "TShortNames", "[ShortName] =
FOSUserName()")

Me.CboName - is the combo box where they currently select their name.
TshortNames -is the table that stores the computer name and their name
FOSUserName- is the function I am using to capture the computer name

The Mainform and Subform record source is using another table that has
the empolyee's name and I need to somehow say after it finds the
Employee name match it to name int he main table and refilter the info.
 
R

Regan via AccessMonster.com

Hi

I think your combo needs more colums, i don;'t know what the record source is
for the Combo box

But maybe something like this for a record source for the combo box

SELECT TshortNames.ID, TshortNames.employeeName FROM TshortNames;

column count 2
Bound column 1
Column widths 0;2.5cm

Then in your code you could put

Me.CboName.value = Dlookup("ID","TshortNames","shortname=""" & fosusername()
& """"

Got to watch them speech marks

Hope this helps

I have a Mainform called "MainPastDue" and a Subform called "PastDues".
Currently when the user logs in they open the Mainform and click on an
Option button and a combo box appears where they can select their name
and it will filter the data in the subform based on there name.

I wanted to automate this process.

I created a table that stores their "ComputerName" and the uers name.
What I would like to happen is to take the computer name look up the
user's name that maps to the computer name and when they click on
option one filter the data automatically to show only their items
instead of them having to select their name.

Here is the code on the Afterupdate of Option 1:

Dim linker
Dim strSQL As String
linker = Frame95.Value
Select Case linker
Case 0
ittype = 0
Me.Cmdclose.SetFocus
Me.FPastDues.Form.FilterOn = False
strSQL = "TARA.NetC=0"
FPastDues.Visible = True
Me.FPastDues.Form.Filter = strSQL
Me.FPastDues.Form.FilterOn = True

What I am trying to add is this:

Me.CboName = DLookup("[EmployeeName]", "TShortNames", "[ShortName] =
FOSUserName()")

Me.CboName - is the combo box where they currently select their name.
TshortNames -is the table that stores the computer name and their name
FOSUserName- is the function I am using to capture the computer name

The Mainform and Subform record source is using another table that has
the empolyee's name and I need to somehow say after it finds the
Employee name match it to name int he main table and refilter the info.

--
Regan,
Paeroa
World famous in New Zealand

Message posted via AccessMonster.com
 
R

Regan via AccessMonster.com

Sorry i mean't Rowsource for you combo box:)
Hi

I think your combo needs more colums, i don;'t know what the record source is
for the Combo box

But maybe something like this for a record source for the combo box

SELECT TshortNames.ID, TshortNames.employeeName FROM TshortNames;

column count 2
Bound column 1
Column widths 0;2.5cm

Then in your code you could put

Me.CboName.value = Dlookup("ID","TshortNames","shortname=""" & fosusername()
& """"

Got to watch them speech marks

Hope this helps
I have a Mainform called "MainPastDue" and a Subform called "PastDues".
Currently when the user logs in they open the Mainform and click on an
[quoted text clipped - 36 lines]
the empolyee's name and I need to somehow say after it finds the
Employee name match it to name int he main table and refilter the info.

--
Regan,
Paeroa
World famous in New Zealand

Message posted via AccessMonster.com
 

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